#include <iostream.h>
class Point
{
public:
Point (int x, int y):myX(x), myY(y) {}
~Point(){}
int GetX() const { return myX; }
void SetX(int x) { myX = x; }
int GetY() const { return myY; }
void SetY(int y) { myY = y; }
private:
int myX;
int myY;
};
class Rectangle
{
public:
Rectangle(Point upperLeft, Point lowerRight):
myUpperLeft(upperLeft),
myLowerRight(lowerRight)
{}
Rectangle(int upperLeftX, int upperLeftY, int lowerRightX, int lowerRightY):
myUpperLeft(upperLeftX,upperLeftY),
myLowerRight(lowerRightX,lowerRightY)
{}
~Rectangle(){}
int GetWidth() { return myLowerRight.GetX() - myUpperLeft.GetX(); }
int GetHeight() { return myLowerRight.GetY() - myUpperLeft.GetY(); }
private:
Point myUpperLeft;
Point myLowerRight;
};
int main()
{
Point ul(0,0);
Point lw(20,30);
Rectangle myRect(ul,lw);
Rectangle otherRect(0,5,20,30);
cout << "myRect measures ";
cout << myRect.GetWidth();
cout << " by " << myRect.GetHeight() << endl;
cout << "otherRect measures ";
cout << otherRect.GetWidth();
cout << " by " << otherRect.GetHeight() << endl;
return 0;
}