-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlight.cpp
More file actions
128 lines (107 loc) · 2.13 KB
/
Copy pathFlight.cpp
File metadata and controls
128 lines (107 loc) · 2.13 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
Flight.cpp
Teng Zhao: 40089560
Thomas Flynn: 40034877
*/
#include "Flight.h"
#include "Employee.h"
Flight::Flight() {
passCounter = 0;
flightNum = 0;
depTime.setTime(0, 0, 0);
arrTime.setTime(0, 0, 0);
depDate.setDate(0, 0, 0);
arrDate.setDate(0, 0, 0);
for (auto& i : employeeList) {
i = nullptr;
}
for (auto& i : passengerList) {
i = nullptr;
}
}
Flight::Flight(int a, int b, int c, int d, int e,int f, int g, int h, int i, int j, int k, int l, int m) {
passCounter = 0;
flightNum = a;
depTime.setTime(b, c, d);
depDate.setDate(e, f, g);
arrDate.setDate(h, i, j);
arrTime.setTime(k, l, m);
for (auto& i : employeeList) {
i = nullptr;
}
for (auto& i : passengerList) {
i = nullptr;
}
}
void Flight::addEmployee(Employee* a) {
if (empCounter < 3) {
for (auto& i : employeeList) {
if (i == nullptr) {
if (a->addFlight(this)) { // used to be i->addFlight(this), This caused the problem
i = a;
empCounter++;
cout << "Successful Added Employee to flight." << endl;
break;
}
}
}
}
else
cout << "Add Employee Failed!" << endl;
}
void Flight::addPassenger(Passenger* a) {
for (auto& i : passengerList) {
if (i == nullptr) {
i = a;
passCounter++;
break;
}
}
}
int Flight::getFlightNum() {
return flightNum;
}
void Flight::getDepTime() {
depTime.printTime();
}
void Flight::getArrTime() {
arrTime.printTime();
}
void Flight::getDepDate() {
depDate.printDate();
}
void Flight::getArrDate() {
arrDate.printDate();
}
bool Flight::isFull(){
if (passCounter < 5)
return false;
if (passCounter >= 5)
return true;
}
void Flight::printPassengerList() {
cout << "Passenger List:" << endl;
for (auto& i : passengerList) {
if (i != nullptr) {
cout << i->getId();
cout << ":";
cout << i->getName() << endl;
}
}
}
void Flight::printEmployeeList() {
cout << "Employee List:" << endl;
for (auto& i : employeeList) {
if (i != nullptr) {
cout << i->getId();
cout << ":";
cout << i->getName() << endl;
}
}
}
void Flight::print(){
cout << "---Flight---" << endl;
cout << flightNum << endl;
this->printPassengerList();
this->printEmployeeList();
}