Assignment #9: Set Operation - Given a class for rectangle as follows;

 

class Rectangle {

      Point *bottomLeft, *upperRight;

      bool  isEmpty; // true if empty rectangle, false otherwise

public:

      Rectangle();

      Rectangle(int, int, int, int);

      Rectangle(Point, Point);

      friend istream& operator>>(istream&, Rectangle&);

      Rectangle operator+(const Rectangle&);

      Rectangle operator-(const Rectangle&);

// add other member functions if necessary

};

class Point {

      int x, y;

public:

      int readX();

      int ready();

};

 

Implement class Rectangle and Point. Note

1. the + operator produces the MBR (Minimum Bounding Rectangle of two operand rectangles) and operator yields the intersection of two rectangles or an empty rectangle (isEmpty=true) if no intersection is found.

2. Input stream >> operator receives four integer coordinates as x1, y1, x2, y2, where x1<=x2 and y1<=y2.

 

Oral test at the lab on May 3rd.

[Download lab.pptx]