1 #include "DerivedRectangle.h"
2
3
4 Rectangle::Rectangle()
5 {
6 width = 1;
7 height = 1;
8 }
9
10
11 Rectangle::Rectangle(double width, double height)
12 {
13 setWidth(width);
14 setHeight(height);
15 }
16
17 Rectangle::Rectangle(
18 double width, double height, const string& color, bool filled)
19 {
20 setWidth(width);
21 setHeight(height);
22 setColor(color);
23 setFilled(filled);
24 }
25
26
27 double Rectangle::getWidth() const
28 {
29 return width;
30 }
31
32
33 void Rectangle::setWidth(double width)
34 {
35 this->width = (width >= 0) ? width : 0;
36 }
37
38
39 double Rectangle::getHeight() const
40 {
41 return height;
42 }
43
44
45 void Rectangle::setHeight(double height)
46 {
47 this->height = (height >= 0) ? height : 0;
48 }
49
50
51 double Rectangle::getArea() const
52 {
53 return width * height;
54 }
55
56
57 double Rectangle::getPerimeter() const
58 {
59 return 2 * (width + height);
60 }
61
62
63 string Rectangle::toString() const
64 {
65 return "Rectangle object";
66 }