-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTram.h
187 lines (171 loc) · 7.21 KB
/
Tram.h
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifndef INC_TRAM_H
#define INC_TRAM_H
#pragma once
#include <string>
#include <set>
class MetroNet;
class Tram {
protected:
friend class ClassTestTram;
Tram* initCheck;
int lijnNr;
int voertuigNr;
int zitplaatsen;
int snelheid;
std::string beginStation;
std::string currentStation;
std::set<std::string> passagiers;
int aantalPassagiers = 0;
int omzet = 0;
const int ticketPrijs = 2;
// CONSTRUCTORS
/**
\n ENSURE(properlyInitialized(), "constructor must end in properlyInitialized state");
*/
Tram(); // default
/**
\n REQUIRE(beginStation != "", "newBeginStation must not be empty");
\n REQUIRE(lijnNr >= 0 , "lijnNr must be bigger or equal to zero");
\n REQUIRE(newVoertuigNr >= 0 , "newVoertuigNr must be bigger or equal to zero");
\n REQUIRE(zitplaatsen >= 0 , "zitplaatsen must be bigger or equal to zero");
\n REQUIRE(snelheid >= 0 , "snelheid must be bigger or equal to zero");
\n ENSURE(properlyInitialized(), "constructor must end in properlyInitialized state");
*/
Tram(const int lijnNr, const int voertuigNr,
const int zitplaatsen, const std::string& beginStation, const int snelheid); // full
public:
// DESTRUCTOR
virtual ~Tram();
// INITIALIZATION CHECK
bool properlyInitialized() const;
// GETTER METHODS
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling getLijnNr");
*/
int getLijnNr() const;
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling getZitplaatsen");
*/
int getZitplaatsen() const;
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling getBeginStation");
*/
std::string getBeginStation() const;
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling getCurrentStation");
*/
std::string getCurrentStation() const;
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling getSnelheid");
*/
int getSnelheid() const;
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling getAantalPassagiers");
*/
int getAantalPassagiers() const;
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling getVoertuigNr");
*/
int getVoertuigNr() const;
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling getOmzet");
*/
int getOmzet() const;
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling isInTram");
\n REQUIRE(passagier != "", "passagier must not be empty");
*/
bool isInTram(std::string passagier) const;
// SETTER METHODS
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling setLijnNr");
\n REQUIRE(newLijnNr >= 0 , "newLijnNr must be bigger or equal to zero");
\n ENSURE(getLijnNr() == newLijnNr, "setLijnNr post condition failure");
*/
void setLijnNr(const int newLijnNr);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling setZitplaatsen");
\n REQUIRE(newZitplaatsen >= 0 , "newZitplaatsen must be bigger or equal to zero");
\n ENSURE(getZitplaatsen() == newZitplaatsen, "setZitplaatsen post condition failure");
*/
void setZitplaatsen(const int newZitplaatsen);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling setBeginStation");
\n REQUIRE(newBeginStation != "", "newBeginStation must not be empty");
\n ENSURE(getBeginStation() == newBeginStation, "setBeginStation post condition failure");
*/
void setBeginStation(const std::string& newBeginStation);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling setCurrentStation");
\n REQUIRE(newCurrentStation != "", "newCurrentStation must not be empty");
\n ENSURE(getCurrentStation() == newCurrentStation, "setCurrentStation post condition failure");
*/
void setCurrentStation(const std::string& newCurrentStation);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling setSnelheid");
\n REQUIRE(newSnelheid >= 0 , "newSnelheid must be bigger or equal to zero");
\n ENSURE(getSnelheid() == newSnelheid, "setSnelheid post condition failure");
*/
void setSnelheid(const int newSnelheid);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling setAantalPassagiers");
\n REQUIRE(newAantalPassagiers >= 0 , "newAantalPassagiers must be bigger or equal to zero");
\n ENSURE(getAantalPassagiers() == newAantalPassagiers, "setAantalPassagiers post condition failure");
*/
void setAantalPassagiers(const int newAantalPassagiers);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling setVoertuigNr");
\n REQUIRE(newVoertuigNr >= 0 , "newVoertuigNr must be bigger or equal to zero");
\n ENSURE(getVoertuigNr() == newVoertuigNr, "setVoertuigNr post condition failure");
*/
void setVoertuigNr(const int newVoertuigNr);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling setOmzet");
\n REQUIRE(newOmzet >= 0 , "newOmzet must be bigger or equal to zero");
\n ENSURE(getOmzet() == newOmzet, "setOmzet post condition failure");
*/
void setOmzet(const int newOmzet);
// MODIFIER METHODS
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling addPassagier");
\n REQUIRE(passagier != "", "passagier must not be empty");
\n REQUIRE(aantal >= 0, "aantal must be bigger or equal to zero");
\n REQUIRE(isInTram(passagier) == false, "passenger allready in Tram");
\n ENSURE(isInTram(passagier) == true, "addPassagier post condition failure");
*/
void addPassagier(std::string passagier, int aantal);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling removePassagier");
\n REQUIRE(passagier != "", "passagier must not be empty");
\n REQUIRE(isInTram(passagier) == true, "passenger not in Tram");
\n ENSURE(isInTram(passagier) == false, "removePassagier post condition failure");
*/
void removePassagier(std::string passagier);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling afstappenInHalte");
\n REQUIRE(metronet.properlyInitialized(), "MetroNet wasn't initialized when calling afstappenInHalte");
\n REQUIRE(station != "", "station must not be empty");
*/
std::set<std::string> afstappenInHalte(MetroNet& metronet, std::string station);
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling moveTram");
\n REQUIRE(metronet.properlyInitialized(), "MetroNet wasn't initialized when calling moveTram");
\n ENSURE(moved || attemptedToMove, "moveTram post condition failure");
\n ENSURE(metronet.isConsistent(), "moveTram made MetroNet inconsistent");
*/
void moveTram(MetroNet& metronet, std::ostream& output);
// VIRTUAL METHODS
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling afstappenInHalte");
\n REQUIRE(metronet.properlyInitialized(), "MetroNet wasn't initialized when calling afstappenInHalte");
\n REQUIRE(station != "", "station must not be empty");
*/
virtual bool stoptInStation(MetroNet& metronet, std::string station) const;
private:
/**
\n REQUIRE(properlyInitialized(), "Tram wasn't initialized when calling moveTram");
\n REQUIRE(metronet.properlyInitialized(), "MetroNet wasn't initialized when calling moveTram");
*/
bool isReachable(MetroNet& metronet, std::string station);
};
#endif /* INC_TRAM_H */