-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeometry.cpp
More file actions
62 lines (50 loc) · 1.01 KB
/
Geometry.cpp
File metadata and controls
62 lines (50 loc) · 1.01 KB
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
#include "Geometry.h"
Point::Point():m_x(0),m_y(0){}
Point::Point(int x, int y):m_x(x),m_y(y){}
Point::~Point()
{
}
bool Point::operator==(const Point& target) const
{
return (this->m_x == target.m_x) && (this->m_y == target.m_y);
}
bool Point::equals(const Point& target) const
{
return (this->m_x == target.m_x) && (this->m_y == target.m_y);
}
void Point::setPosition(int x, int y)
{
this->m_x = x;
this->m_y = y;
}
void Point::move(DIR dir,int speed)
{
switch (dir)
{
case DIR::UP:
m_y -= speed;
break;
case DIR::DOWN:
m_y += speed;
break;
case DIR::LEFT:
m_x -= speed;
break;
case DIR::RIGHT:
m_x += speed;
break;
}
}
//****************Size********************
Size::Size():width(0),height(0){}
Size::Size(int width, int height):width(width),height(height){}
Size::~Size(){}
void Size::setSize(int width, int height)
{
this->width = width;
this->height = height;
}
bool Size::equals(const Size& target) const
{
return (this->width == target.width) && (this->height == target.height);
}