Ejemplo n.º 1
0
void PrintGeometricObject::PrintObject(Rectangle& r)
{
	// Todo
	cout << "Rectangle\n";
	cout << "  length:        " << r.length_ << " " << r.measurementUnit_ << "\n";
	cout << "  height:        " << r.height_ << " " << r.measurementUnit_ << "\n";
	cout << "  circumference: " << r.Circumference() << " " << r.measurementUnit_ << "\n";
	cout << "  area:          " << r.Area() << " " << r.measurementUnit_ << "^2\n";
	cout << "  the rectangle " << (r.IsSquare() ? "is " : "is not ") << "a square.\n\n";
}
Ejemplo n.º 2
0
 int InclusiveArea (Rectangle &r){
     // I include it
     if (r.topLeft.x >= topLeft.x && r.bottomRight.x <= bottomRight.x &&
             r.topLeft.y <= topLeft.y && r.bottomRight.y >= bottomRight.y ) {
         return this->Area();
     }
     // it includes me
     if (r.topLeft.x <= topLeft.x && r.bottomRight.x >= bottomRight.x &&
             r.topLeft.y >= topLeft.y && r.bottomRight.y <= bottomRight.y ) {
         return r.Area();
     }
     // 0 - no inclusive
     return 0;
 }
Ejemplo n.º 3
0
bool Rectangle::operator!=(const Rectangle& other) const
{
   return Area()!=other.Area();
}
Ejemplo n.º 4
0
bool Rectangle::operator<(const Rectangle& other) const
{
   return Area()<other.Area();
}
Ejemplo n.º 5
0
void process(Rectangle &r) {
    int w = r.getWidth();
    r.setHeight(10);

    cout << "Expect area = " << (w*10) << ", got " << r.Area() << endl;
}