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"; }
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; }
bool Rectangle::operator!=(const Rectangle& other) const { return Area()!=other.Area(); }
bool Rectangle::operator<(const Rectangle& other) const { return Area()<other.Area(); }
void process(Rectangle &r) { int w = r.getWidth(); r.setHeight(10); cout << "Expect area = " << (w*10) << ", got " << r.Area() << endl; }