-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.cpp
More file actions
63 lines (53 loc) · 860 Bytes
/
Utils.cpp
File metadata and controls
63 lines (53 loc) · 860 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
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
//
// Created by Ziyang Zhang on 2019-05-03.
//
#include "Utils.h"
Position::Position(int x,int y)
:x(x),y(y)
{
}
int& Position::operator[] (const int& index)
{
if (index == 0)
{
return this->x;
}
else if (index == 1)
{
return this->y;
}
else
{
throw IndexOutOfBoundError();
}
}
bool Position::operator== (const Position& lp) const
{
return lp.x == x && lp.y == y;
}
bool Position::operator< (const Position& rp) const
{
if (x < rp.x)
{
return true;
}
else if (x == rp.x)
{
if (y < rp.y)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
std::vector<Position> Direction::operator[] (const std::string& index)
{
return list.at(index);
}