-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCity.cpp
85 lines (71 loc) · 1.14 KB
/
City.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
77
78
79
80
81
82
83
84
85
#include "City.h"
City::City()
{
id = 0;
xPosition = 0;
yPosition = 0;
lootValue = 0;
lootVolume = 0;
}
City::City(int i, int x, int y, int val, int vol, bool isBorder)
{
id = i;
xPosition = x;
yPosition = y;
lootValue = val;
lootVolume = vol;
border = isBorder;
}
int City::getXPosition()
{
return xPosition;
}
int City::getId()
{
return id;
}
int City::getYPosition()
{
return yPosition;
}
std::string City::getName()
{
return name;
}
int City::getLootValue()
{
return lootValue;
}
int City::getLootVolume()
{
return lootVolume;
}
bool City::isNeighbour(City* potentialNeighbour)
{
for (auto a : edges)
if (a == potentialNeighbour)
{
return true;
}
return false;
}
bool City::isOnBorder()
{
return border;
}
std::vector<City*>* City::getEgdes()
{
return &edges;
}
void City::addEdge(City* newNeighbour)
{
edges.push_back(newNeighbour);
}
double City::getDistance(City* targetCity)
{
double distance, xDistance, yDistance;
xDistance = abs(xPosition - targetCity->getXPosition());
yDistance = abs(yPosition - targetCity->getYPosition());
distance = sqrt(xDistance*xDistance + yDistance*yDistance);
return distance;
}