-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoord.cpp
More file actions
29 lines (24 loc) · 739 Bytes
/
coord.cpp
File metadata and controls
29 lines (24 loc) · 739 Bytes
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
#include <assert.h>
#include <math.h>
#include "coord.h"
Coord::Coord(const Coord& Coord) : x(Coord.x), y(Coord.y) {}
Coord::Coord(int _x, int _y) : x(_x), y(_y) {}
bool Coord::isNeighbour(const Coord& coord) const {
if (this->x + 1 == coord.x && this->y == coord.y)
return true;
if (this->x - 1 == coord.x && this->y == coord.y)
return true;
if (this->x == coord.x && this->y + 1 == coord.y)
return true;
if (this->x == coord.x && this->y - 1 == coord.y)
return true;
return false;
}
bool Coord::operator==(const Coord& autre) const {
return this->x == autre.x && this->y == autre.y;
}
bool Coord::operator<(const Coord& autre) const {
if (this->x == autre.x)
return this->y < autre.y;
return this->x < autre.x;
}