Skip to content

Commit dd273b6

Browse files
authored
Implemented the ninth, tenth and eleventh menu options
In data.h file: Declared: - Passenger class and functionality to it In data.cpp file: Implemented: - functionality for Passenger class In function.h file: Declared: - new functions for Passenger class and others In function.cpp file: Implemented: - new functions for Passenger class and others In workers.h file: Declared: - vector of passengers data In main.cpp file: Added: - new functionality
1 parent faf6923 commit dd273b6

File tree

6 files changed

+502
-50
lines changed

6 files changed

+502
-50
lines changed

Database/data.cpp

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,95 @@ bool Human::getThePresenceOfChildren()
8484
}
8585

8686

87+
//PASSENGER CLASS
88+
89+
//default constructor for the Passenger class
90+
Passenger::Passenger()
91+
{
92+
this->setName("");
93+
this->setSurname("");
94+
this->setAge(0);
95+
this->setSex("");
96+
97+
this->setRoute("");
98+
this->setLuggage("");
99+
this->setDepDate("");
100+
this->setDepAbroadDate("");
101+
};
102+
103+
//overloaded constructor for the Passenger class
104+
Passenger::Passenger(std::string name, std::string surname, int age, std::string sex,
105+
std::string route, std::string depDate, std::string depAbroadDate, std::string luggage)
106+
{
107+
this->setName(name);
108+
this->setSurname(surname);
109+
this->setAge(age);
110+
this->setSex(sex);
111+
112+
this->setRoute(route);
113+
this->setDepDate(depDate);
114+
this->setDepAbroadDate(depAbroadDate);
115+
this->setLuggage(luggage);
116+
};
117+
118+
//default destructor for the Passenger class
119+
Passenger::~Passenger(){};
120+
121+
//setters for the Passenger class
122+
void Passenger::setRoute(std::string route)
123+
{
124+
this->route = route;
125+
}
126+
void Passenger::setDepDate(std::string date)
127+
{
128+
this->depDate = date;
129+
}
130+
void Passenger::setDepAbroadDate(std::string date)
131+
{
132+
this->depAbroadDate = date;
133+
}
134+
void Passenger::setLuggage(std::string luggage)
135+
{
136+
this->luggage = luggage;
137+
}
138+
139+
//getters for the Passenger class
140+
std::string Passenger::getRoute()
141+
{
142+
return route;
143+
}
144+
145+
std::string Passenger::getDepDate()
146+
{
147+
return depDate;
148+
}
149+
150+
std::string Passenger::getDepAbroadDate()
151+
{
152+
return depAbroadDate;
153+
}
154+
155+
std::string Passenger::getLuggage()
156+
{
157+
return luggage;
158+
}
159+
160+
//overloaded output function for Worker class
161+
void Passenger::outputPass(Passenger &el)
162+
{
163+
std::cout << "--------------------------------------------------------------" << std::endl
164+
<< "Name & surname: " << el.getName() << ' '
165+
<< el.getSurname() << std::endl
166+
<< "Age: " << el.getAge() << std::endl
167+
<< "Sex: " << el.getSex() << std::endl
168+
<< "Luggage: " << el.getLuggage() << std::endl
169+
<< "Route: " << el.getRoute() << std::endl
170+
<< "Day of departure: " << el.getDepDate() << std::endl
171+
<< "Day of departure abroad: " << el.getDepAbroadDate() << std::endl
172+
<< "--------------------------------------------------------------" << std::endl;
173+
}
174+
175+
87176
//WORKER CLASS
88177

89178
//default constructor for the Worker class
@@ -383,6 +472,10 @@ void Train::setNumOfHandedTickets(int num)
383472
{
384473
this->numOfHandedTickets = num;
385474
}
475+
void Train::setNumOfSoldTickets(int num)
476+
{
477+
this->numOfSoldTickets = num;
478+
}
386479

387480
//getters for the "Locomotive" class
388481
int Train::getSerialNum()
@@ -457,6 +550,10 @@ int Train::getNumOfHandedTickets()
457550
{
458551
return numOfHandedTickets;
459552
}
553+
int Train::getNumOfSoldTickets()
554+
{
555+
return numOfSoldTickets;
556+
}
460557

461558
//output function for the "Locomotive" class
462559
void Locomotive::outputLoc(Locomotive &el)
@@ -511,7 +608,7 @@ Locomotive::Locomotive(int serialNum, int workspaceNum, int dateOfProd, int maxs
511608
std::string brand, std::string fuel, int numOfRoutes, int numOfRoutesBeforeRepair,
512609
int numOfRepair, std::string dateOfComeBack, int daysOnStation, std::string yearOfTechExam,
513610
std::string routeStatus, std::string routeReason, std::string category, int routeDuration,
514-
std::string route, int numOfHandedTickets)
611+
std::string route, int numOfSoldTickets, int numOfHandedTickets)
515612
{
516613
this->setSerialNum(serialNum);
517614
this->setWorkspaceNum(workspaceNum);
@@ -530,6 +627,7 @@ Locomotive::Locomotive(int serialNum, int workspaceNum, int dateOfProd, int maxs
530627
this->setCategory(category);
531628
this->setRouteDuration(routeDuration);
532629
this->setRoute(route);
630+
this->setNumOfSoldTickets(numOfSoldTickets);
533631
this->setNumOfHandedTickets(numOfHandedTickets);
534632
};
535633

Database/data.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,35 @@ class Human
6161
void output(Human &el);
6262
};
6363

64+
class Passenger : public Human
65+
{
66+
private:
67+
std::string route;
68+
std::string depDate;
69+
std::string depAbroadDate;
70+
std::string luggage;
71+
public:
72+
Passenger();
73+
Passenger(std::string name, std::string surname, int age, std::string sex,
74+
std::string route, std::string depDate, std::string depAbroadDate, std::string luggage);
75+
~Passenger();
76+
77+
//setters
78+
void setRoute(std::string route);
79+
void setDepDate(std::string date);
80+
void setDepAbroadDate(std::string date);
81+
void setLuggage(std::string luggage);
82+
83+
//getters
84+
std::string getRoute();
85+
std::string getDepDate();
86+
std::string getDepAbroadDate();
87+
std::string getLuggage();
88+
89+
//function for outputting data
90+
void outputPass(Passenger &el);
91+
};
92+
6493
class Worker : public Human
6594
{
6695
private:
@@ -177,6 +206,7 @@ class Train
177206
std::string routeReason;
178207
std::string category;
179208
int routeDuration;
209+
int numOfSoldTickets;
180210
int numOfHandedTickets;
181211

182212
public:
@@ -202,6 +232,7 @@ class Train
202232
void setRouteDuration(int duration);
203233
void setRoute(std::string route);
204234
void setNumOfHandedTickets(int num);
235+
void setNumOfSoldTickets(int num);
205236

206237
//getters
207238
int getSerialNum();
@@ -222,6 +253,7 @@ class Train
222253
int getRouteDuration();
223254
std::string getRouteReason();
224255
int getNumOfHandedTickets();
256+
int getNumOfSoldTickets();
225257
};
226258

227259
class Locomotive : public Train
@@ -233,7 +265,7 @@ class Locomotive : public Train
233265
std::string brand, std::string fuel, int numOfRoutes, int numOfRoutesBeforeRepair,
234266
int numOfRepair, std::string dateOfComeBack, int daysOnStation, std::string yearOfTechExam,
235267
std::string routeStatus, std::string routeReason, std::string category, int routeDuration,
236-
std::string route, int numOfHandedTickets);
268+
std::string route, int numOfSoldTickets, int numOfHandedTickets);
237269
~Locomotive();
238270

239271
void outputLoc(Locomotive &el);

0 commit comments

Comments
 (0)