-
Notifications
You must be signed in to change notification settings - Fork 20
/
point.cc
86 lines (66 loc) · 1.21 KB
/
point.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* point.cpp
*
* Created on: Feb 12, 2013
* Author: Vadim Fedorov
*/
/**
* Copyright (C) 2013, Vadim Fedorov <vadim.fedorov@upf.edu>
*
* This program is free software: you can use, modify and/or
* redistribute it under the terms of the simplified BSD
* License. You should have received a copy of this license along
* this program. If not, see
* <http://www.opensource.org/licenses/bsd-license.html>.
*/
#include "point.h"
Point::Point()
{
x = 0;
y = 0;
}
Point::Point(float x, float y)
{
this->x = x;
this->y = y;
}
bool Point::operator== (const Point &p) const
{
return (this->x == p.x) && (this->y == p.y);
}
bool Point::operator!= (const Point &p) const
{
return !((*this) == p);
}
Point& Point::operator= (const Point &p)
{
if (this != &p) {
this->x = p.x;
this->y = p.y;
}
return *this;
}
Point& Point::operator+= (const Point &p)
{
x += p.x;
y += p.y;
return *this;
}
Point& Point::operator-= (const Point &p)
{
x -= p.x;
y -= p.y;
return *this;
}
const Point Point::operator+ (const Point &p) const
{
Point result = *this;
result += p;
return result;
}
const Point Point::operator- (const Point &p) const
{
Point result = *this;
result -= p;
return result;
}