-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rectangle.cc
52 lines (35 loc) · 952 Bytes
/
Rectangle.cc
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
#include "Rectangle.hh"
#include <cassert>
using namespace std;
/** Constructor. */
Rectangle::Rectangle (double w, double h, const Point& p)
: p(p),
w(w),
h(h)
{
assert(w >= 0);
assert(h >= 0);
}
/** Gets the LL (lower-left) point of this rectangle. */
Point Rectangle::get_LL () const {
return p;
}
/** Gets the UR (upper-right) point of this rectangle. */
Point Rectangle::get_UR () const {
return Point(p.get_x() + w, p.get_y() + h);
}
/** Gets the area of this rectangle. */
double Rectangle::area () const {
return w * h;
}
/** Gets the width of this rectangle. */
double Rectangle::width () const {
return w;
}
/** Gets the height of this rectangle. */
double Rectangle::height () const {
return h;
}
// ***********************************************************
// Implement the rest of the Rectangle methods by yourself !!!
// ***********************************************************