-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangle.cpp
More file actions
46 lines (34 loc) · 866 Bytes
/
Rectangle.cpp
File metadata and controls
46 lines (34 loc) · 866 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
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <cstdint>
#include "Rectangle.h"
/*********************************
* A simple class for a Rectangle,
* which knows it's width and height.
* And can calculate it's area.
*********************************/
Rectangle::Rectangle() {
bIsValid = false;
setValues(0,0);
}
Rectangle::Rectangle(uint32_t x, uint32_t y) {
bIsValid = false;
setValues(x, y);
}
bool Rectangle::isValid() {
return bIsValid;
}
void Rectangle::setValues (uint32_t x, uint32_t y) {
width = x;
height = y;
if (width > 0 && height > 0) bIsValid = true;
}
void Rectangle::setX (uint32_t val) {
width = val;
if (width > 0 && height > 0) bIsValid = true;
}
void Rectangle::setY (uint32_t val) {
height = val;
if (width > 0 && height > 0) bIsValid = true;
}
uint32_t Rectangle::getArea() {
return width*height;
}