#include "Rectangle.h" Rectangle::Rectangle() { xPosition = 0; yPosition = 0; width = 0; height = 0; } Rectangle::Rectangle(int xPositionArg, int yPositionArg, int heightArg, int widthArg) { xPosition = xPositionArg; yPosition = yPositionArg; width = widthArg; height = heightArg; } Rectangle::~Rectangle() { // nothing to do here in destructor } int Rectangle::getHeight() { return height; } void Rectangle::setHeight(int heightArg) { height = heightArg; } int Rectangle::getWidth() { return width; } void Rectangle::setWidth(int widthArg) { width = widthArg; } int Rectangle::getXPosition() { return xPosition; } void Rectangle::setXPosition(int xPositionArg) { xPosition = xPositionArg; } int Rectangle::getYPosition() { return yPosition; } void Rectangle::setYPosition(int yPositionArg) { yPosition = yPositionArg; } int Rectangle::getArea() { return width * height; } int Rectangle::getPerimeter() { return (2 * width) + (2 * height); } bool Rectangle::overlaps(const Rectangle & r) { if (pointInside(r.xPosition, r.yPosition) == true) return true; else if (pointInside(r.xPosition + r.width, r.yPosition) == true) return true; else if (pointInside(r.xPosition, r.yPosition+r.height) == true) return true; else if (pointInside(r.xPosition + r.width, r.yPosition + r.height) == true) return true; else return false; } bool Rectangle::pointInside(int xArg, int yArg) { if ((xArg >= xPosition) && (xArg <= (xPosition + width)) && (yArg >= yPosition) && (yArg <= (yPosition+height))) return true; else return false; }