-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.cpp
More file actions
55 lines (52 loc) · 1.1 KB
/
Point.cpp
File metadata and controls
55 lines (52 loc) · 1.1 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
#include "Point.h"
#include "Utils.h"
//constructor
Point::Point() : x(-1), y(-1) {}
Point::Point(const signed long x, const signed long y) {
this->x = x;
this->y = y;
}
//== overloading
bool Point::operator== (const Point& B) const{
return getX() == B.getX() && getY() == B.getY();
}
//!= overloading
bool Point::operator!= (const Point& B) const {
return !(*this == B);
}
//set X coordinate
void Point::setX(const signed long x) {
this->x = x;
}
//set Y coordinate
void Point::setY(const signed long y) {
this->y = y;
}
//increase X coordinate
void Point::increaseX() {
this->x++;
}
//increase Y coordinate
void Point::increaseY() {
this->y++;
}
//decrease X coordinate
void Point::decreaseX() {
this->x--;
}
//decrease Y coordinate
void Point::decreaseY() {
this->y--;
}
//get X coordinate
signed long const Point::getX() const {
return this->x;
}
//get Y coordinate
signed long const Point::getY() const {
return this->y;
}
//print point
string const Point::toString() const {
return "X=" + to_string(this->x) + " " + "Y=" + to_string(this->y);
}