-
Notifications
You must be signed in to change notification settings - Fork 1
/
station.cpp
65 lines (49 loc) · 1.81 KB
/
station.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
// D O W N W I T H M A T T H E W A H N
#include "station.h"
// C O N S T R U C T O R S
Station::Station(): name{"NONE"}, visited{false} {}
Station::Station(int inId, std::string inName, double lon, double lat, std::list<std::pair<std::string,int>> inLines):
id {inId},
name {std::move(inName)},
cords {lon, lat},
lines {std::move(inLines)},
open {true},
visited {false}
{//list has default constructor, so we should be good on this end
}
// G E T T E R S
std::string Station::getCordStr() const {
return "(" + std::to_string(cords.first) + ", " + std::to_string(cords.second) + ")";
}
void Station::addLine(std::pair<std::string, int> line) {
lines.push_back(std::move(line));
}
void Station::setTrips(std::list<Trip> inTrips){
trips = std::move(inTrips);
}
void Station::addTrip(Trip inTrip){
trips.push_back(std::move(inTrip));
}
void Station::addLine(std::string inStr, int inIndex){
lines.emplace_back(std::move(inStr), inIndex);
}
void Station::removeDups(){
for(auto iter1 = trips.begin(); iter1 != trips.end(); iter1++){
for(auto iter2 = iter1; iter2 != trips.end(); iter2++){
if( iter1->isDup(*iter2) ){
iter2 = trips.erase(iter2);
}
}
}
}
std::ostream& operator<<(std::ostream& os, const Station& s){
os << s.getId() << " | ";
os << s.getName()<< " | ";
os << s.getCordStr() << std::endl;
os << " Trips";
os << " ";
for(const Trip &t: s.getTrips()){
os << " " << t.getStart() << "------>" << t.getEnd() << " Type: " << t.getType() << std::endl;
}
return os;
}