-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBooking.cpp
More file actions
57 lines (49 loc) · 966 Bytes
/
Copy pathBooking.cpp
File metadata and controls
57 lines (49 loc) · 966 Bytes
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
/*
Booking.cpp
Teng Zhao: 40089560
Thomas Flynn: 40034877
*/
#include "Booking.h"
#include "Flight.h"
#include "Passenger.h"
Booking::Booking(){
seatNum = " ";
passenger = nullptr;
flight = nullptr;
}
Booking::Booking(Passenger* a, Flight* b, string c) {
passenger = a;
flight = b;
seatNum = c;
if(! (b->isFull())){
if (addPassenger(a)) {
b->addPassenger(a);
cout << "Booking Successful!" << endl;
}
}
else {
passenger = nullptr;
flight = nullptr;
cout << "Booking Failed! Try again!" << endl;
}
}
void Booking::setSeatNum(string a) {
seatNum = a;
}
bool Booking::addPassenger(Passenger* p) {
if (p->addBooking(this)) {
passenger = p;
return true;
}
return false;
}
string Booking::getSeatNum() {
return seatNum;
}
void Booking::print() {
cout << "----------" << endl;
cout << "Booking:" << endl;
cout << "Seat Number: " << seatNum << endl;
passenger->print();
cout << "Flight: " << flight->getFlightNum() << endl;
}