I need help understanding this block of text
Write your question here.
I don't understand what the extra uses of point are in the rectangle class, I need some insight :Y
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <iostream>
class Point
{
// no constructor, use default
public:
void setX(int newX) { x = newX; }
void setY(int newY) { y = newY; }
int getX() const { return x;}
int getY() const { return y;}
private:
int x;
int y;
};
class Rectangle
{
public:
Rectangle(int newTop, int newLeft, int newBottom, int newRight);
~Rectangle() {}
int getTop() const { return top; }
int getLeft() const { return left; }
int getBottom() const { return bottom; }
int getRight() const { return right; }
Point getUpperLeft() const { return upperLeft; }
Point getLowerLeft() const { return lowerLeft; }
Point getUpperRight() const { return upperRight; }
Point getLowerRight() const { return lowerRight; }
void setUpperLeft(Point location);
void setLowerLeft(Point location);
void setUpperRight(Point location);
void setLowerRight(Point location);
void setTop(int newTop);
void setLeft (int newLeft);
void setBottom (int newBottom);
void setRight (int newRight);
int getArea() const;
private:
Point upperLeft;
Point upperRight;
Point lowerLeft;
Point lowerRight;
int top;
int left;
int bottom;
int right;
};
|
The Point at the bottom is the actual values of the points, the upper points are the functions that return a Point.
Topic archived. No new replies allowed.