-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAirlineReservation.cpp
211 lines (183 loc) · 5.18 KB
/
AirlineReservation.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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// AirlineReservation9-2-2019.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include "Database.h"
using namespace AirlineApp;
using namespace std;
int displayMenu();
void addPassenger(Database& db, int flightSelection);
void getPassenger(Database& db);
void addFlight(Database& db);
void getFlight(Database& db);
void printFlight(Database& db);
int selectFlight(Database& db);
void displayTicket(Database& db);
int main()
{
Database passengersDb;
addFlight(passengersDb);
while (true) {
int selection = displayMenu();
switch (selection) {
case 0:
return 0;
case 1:
{
int flightSelection = selectFlight(passengersDb);
//add switch case here
switch (flightSelection) {
case 0:
break;
case 1:
cout << "You picked flight 100" << endl;
addPassenger(passengersDb, flightSelection);
break;
case 2:
cout << "You picked flight 101" << endl;
addPassenger(passengersDb, flightSelection);
break;
case 3:
cout << "You picked flight 102" << endl;
addPassenger(passengersDb, flightSelection);
break;
case 4:
cout << "You picked flight 103" << endl;
addPassenger(passengersDb, flightSelection);
break;
case 5:
cout << "You picked flight 104" << endl;
addPassenger(passengersDb, flightSelection);
break;
default:
cerr << "Unknown command. Please try again." << endl;
break;
}
break;
}
case 2:
printFlight(passengersDb);
break;
case 3:
getPassenger(passengersDb);
break;
case 4:
getFlight(passengersDb);
break;
case 5:
displayTicket(passengersDb);
break;
default:
cerr << "Unknown command. Please try again." << endl;
break;
}
}
}
void displayTicket(Database& db) {
string firstName;
string lastName;
cout << "First Name: ";
cin >> firstName;
cout << "Last Name: ";
cin >> lastName;
db.getPassenger(firstName, lastName).displayTicketInformation();
}
void getFlight(Database& db) {
int flightNumber;
cout << endl;
cout << "Please Enter the Flight Number:";
cin >> flightNumber;
cout << endl;
cout << "Flight Number" << " " << "Departure Time" << " " << "Arrival Time" << endl;
cout << endl;
db.getFlight(flightNumber).displayFlight();
cout << endl;
}
void addFlight(Database& db) {
db.addFlight();
db.addFlight();
db.addFlight();
db.addFlight();
db.addFlight();
}
void printFlight(Database& db) {
cout << "Flights from Seattle to Vancouver:" << endl;
cout << endl;
cout << "Flight Number" << " " << "Departure Time" << " " << "Arrival Time" << endl;
cout << endl;
db.printFlights();
}
void addPassenger(Database& db, int flightSelection)
{
string firstName;
string lastName;
Flight& flight = db.getFlight(flightSelection);
cout << "First Name: ";
cin >> firstName;
cout << "Last Name: ";
cin >> lastName;
db.addPassenger(flight, firstName, lastName);
cout << endl;
cout << "Thanks " << firstName << " " << lastName << "!" << endl;
cout << endl;
cout << "Ticket Information: " << endl;
db.getPassenger(firstName, lastName).displayPassenger();
}
void getPassenger(Database& db)
{
int ticketNumber;
cout << "Ticket Number: ";
cin >> ticketNumber;
db.getPassenger(ticketNumber).displayPassenger();
}
int selectFlight(Database& db)
{
int flightSelection;
cout << endl;
cout << "Please choose a flight: " << endl;
cout << endl;
cout << "Flight Number" << " " << "Departure Time" << " " << "Arrival Time" << endl;
cout << endl;
cout << "1. ";
db.getFlight(100).displayFlight();
cout << "2. ";
db.getFlight(101).displayFlight();
cout << "3. ";
db.getFlight(102).displayFlight();
cout << "4. ";
db.getFlight(103).displayFlight();
cout << "5. ";
db.getFlight(104).displayFlight();
cout << endl;
cout << endl;
cout << "0. Return to main menu." << endl;
cout << endl;
cin >> flightSelection;
return flightSelection;
}
int displayMenu()
{
int selection;
cout << endl;
cout << "Welcome to CS Airways." << endl;
cout << "We are excited to offer daily flights from Seattle to Vancouver!" << endl;
cout << endl;
cout << "Please Select an Option: " << endl;
cout << "1. Reserve a seat" << endl;
cout << "2. Flight Schedule" << endl;
cout << "3. Display Passenger information" << endl;
cout << "4. Flight Details" << endl;
cout << "5. Ticket information" << endl;
cout << "0. Exit" << endl;
cout << endl;
cin >> selection;
return selection;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file