-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCity.hpp
58 lines (49 loc) · 769 Bytes
/
City.hpp
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
/*
* City.hpp
* Models a city
*
*/
#ifndef CITY_HPP
#define CTTY_HPP
#include <opencv2/core.hpp>
#include <cmath>
#include <string>
class City
{
public:
int m_x;
int m_y;
cv::RNG myrng;
public:
City()
{
myrng = cv::RNG(cv::getTickCount());
m_x = myrng.uniform(0, 200);
m_y = myrng.uniform(0, 200);
}
City(int x, int y)
{
m_x = x;
m_y = y;
}
int getX()
{
return m_x;
}
int getY()
{
return m_y;
}
double distanceTo(City city)
{
int xDistance = fabs(getX() - city.getX());
int yDistance = fabs(getY() - city.getY());
double distance = sqrt((xDistance * xDistance) + (yDistance * yDistance));
return distance;
}
std::string toString()
{
return std::to_string(getX()) + ", " + std::to_string(getY());
}
};
#endif