-
Notifications
You must be signed in to change notification settings - Fork 0
/
Coords.cpp
76 lines (64 loc) · 1.01 KB
/
Coords.cpp
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
#include "Coords.h"
Coords Coords::operator-() const
{
return Coords(-_x, -_y);
}
Coords &Coords::operator+=(const Coords &rhs)
{
_x += rhs._x;
_y += rhs._y;
return *this;
}
Coords &Coords::operator-=(const Coords &rhs)
{
*this += -rhs;
return *this;
}
Coords Coords::operator+(const Coords &rhs) const
{
Coords res{ *this };
res += rhs;
return res;
}
Coords Coords::operator-(const Coords &rhs) const
{
Coords res{ *this };
res -= rhs;
return res;
}
Coords &Coords::operator*=(int mul)
{
_x *= mul;
_y *= mul;
return *this;
}
Coords &Coords::operator*=(double mul)
{
_x *= mul;
_y *= mul;
return *this;
}
Coords &Coords::operator/=(int div)
{
_x /= div;
_y /= div;
return *this;
}
Coords Coords::operator*(int mul) const
{
Coords res{ *this };
res *= mul;
return res;
}
Coords Coords::operator*(double mul) const
{
Coords res{ *this };
res *= mul;
return res;
}
Coords Coords::operator/(int div) const
{
Coords res{ *this };
res /= div;
return res;
}