-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.cpp
More file actions
33 lines (25 loc) · 860 Bytes
/
Copy pathSquare.cpp
File metadata and controls
33 lines (25 loc) · 860 Bytes
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
#include "Square.h"
// Square Constructor
Square::Square(double length, double x, double y) {
this->length = length; // Sets length of square
shapeType = ShapeType::SQUARE; // Sets the type of shape
// Sets the four points of the square
bottomLeft.setPoint(x, y);
topLeft.setPoint(x,y+length);
topRight.setPoint(x+length, y+length);
bottomRight.setPoint(x+length, y);
// Adds the points of the square to shape's points
points = {&bottomLeft, &topLeft, &topRight, &bottomRight};
};
// Returns the radius of the circle
double Square::getRadiusOrLength() {
return length;
}
// Prints the points and length of the square
void Square::printShape() {
cout << "| Square | Points = ";
for (Point* point : points) {
point->printPoint();
}
cout << "| Length = " << getRadiusOrLength() << " |";
}