-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rectangle.h
68 lines (63 loc) · 1.41 KB
/
Rectangle.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef RECTANGLE_H
#define RECTANGLE_H
#include "commonHeaders.h"
class Rect
{
private:
ULONG m_left;
ULONG m_top;
ULONG m_right;
ULONG m_bottom;
public:
Rect () {m_left = m_top = m_right = m_bottom = 0;}
Rect (ULONG left,
ULONG top,
ULONG right,
ULONG bottom)
{
m_left = left;
m_top = top;
m_right = right;
m_bottom= bottom;
}
long getWidth()
{
return m_right - m_left;
}
long getHeight()
{
return m_bottom - m_top;
}
long getArea()
{
return getWidth() * getHeight();
}
long getLeft()
{
return m_left;
}
long getRight()
{
return m_right;
}
long getTop()
{
return m_top;
}
long getBottom()
{
return m_bottom;
}
Rect &operator= (const Rect &r)
{
if (this != &r)
{
m_left = r.m_left;
m_right = r.m_right;
m_top = r.m_top;
m_bottom= r.m_bottom;
}
return *this;
}
};
#endif