-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocation.h
More file actions
112 lines (83 loc) · 1.81 KB
/
Location.h
File metadata and controls
112 lines (83 loc) · 1.81 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef LOCATION_H
#define LOCATION_H
#include <string>
#include <vector>
#include "Route.h"
class Route;
using namespace std;
class Location{
public:
string country;
string capital;
float lat;
float lon;
vector<Route*> routes;
bool exists;
Location* previous;
float lengthFromStart;
Location();
~Location();
Location(string count, string cap);
Location(string count, string cap, float lt, float lg);
float getWeight(Location* start, Location* end);
int operator== (const Location &rhs) const;
int operator< (const Location &rhs) const;
int operator> (const Location &rhs) const;
bool operator()(Location& l1, Location& l2);
};
Location::Location(){
country = "";
capital = "";
lat = 0;
lon = 0;
// Used as a highest value possible for comparison purposes
lengthFromStart = 999999;
exists = true;
previous = NULL;
}
Location::~Location(){};
Location::Location(string count, string cap){
country = count;
capital = cap;
lat = 0;
lon = 0;
lengthFromStart = 999999;
exists = true;
previous = NULL;
}
Location::Location(string count, string cap, float lt, float lg){
country = count;
capital = cap;
lat = lt;
lon = lg;
lengthFromStart = 999999;
exists = true;
previous = NULL;
}
int Location::operator== (const Location &rhs) const{
if(this -> capital.compare(rhs.capital) == 0){
return 0;
}
return 1;
}
int Location::operator< (const Location &rhs) const{
if(this -> lengthFromStart < rhs.lengthFromStart){
return 1;
}
}
int Location::operator> (const Location &rhs) const{
if(this -> lengthFromStart > rhs.lengthFromStart){
return 1;
}
}
class compareLocation{
public:
bool operator()(const Location* l1, const Location* l2) const{
bool output = false;
if(l1->lengthFromStart > l2->lengthFromStart){
output = true;
}
return output;
}
};
#endif