-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflySRM.cpp
286 lines (286 loc) · 10.8 KB
/
flySRM.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#include <iostream>
#include <string>
using namespace std;
class flySRM
{
public:
string from, to, feedback;
int day, month, year, num, fclass, amt, booking, meal, luggage, ff, offer, date_fee; //global variables
flySRM() //constructor to initialize global variables
{
from="";
to="";
day=0;
month=0;
year=0;
num=0;
fclass=0;
amt=0;
booking=0;
meal=0;
luggage=0;
ff=0;
offer=0;
date_fee=0;
feedback="You have not given a feedback as of now!\n";
}
public: void book() //function to book flights
{
if(booking==1)
{
cout<<"You already have a booking with flySRM!\n";
return;
}
cout<<"From: ";
cin>>from;
cout<<"To: ";
cin>>to;
cout<<"Date: ";
cin>>day>>month>>year;
if(day<0 || month<0 || year<0 || (month==2 && day>29) || ((month==4 || month==6 || month==9 || month==11) && day>30) || day>31)
{ //checking if the entered date is valid or not
cout<<"Invalid date entered! Please try again from the main menu!\n";
return;
}
cout<<"Which class do you want to fly?";
cout<<"\n1) Executive\n2) Business\nOther) Economy\n\nEnter your choice by entering the code: ";
cin>>fclass;
cout<<"Number of Passengers: ";
cin>>num;
if(fclass==1)
amt=num*10000;
else if(fclass==2)
amt=num*7500;
else
amt=num*5000;
cout<<"Do you want to book a meal? Press 1 to select YES, any other key for NO: ";
cin>>meal;
cout<<"Do you want extra luggage weight? Press 1 to select YES, any other key for NO: ";
cin>>luggage;
cout<<"Are you a frequent flyer? Press 1 to select YES, any other key for NO: ";
cin>>ff;
cout<<"We have some special offers for you! Select ONE that is applicable with the given codes, or press any other key to proceed";
cout<<"\n1) Student Offer\n2) Defence Personnel Offer\n3) First Time flySRM Customer Offer\n4) Elders Offer\nEnter your choice: ";
cin>>offer;
booking=1; //setting booking to TRUE
if(offer==1) //offers
{
cout<<"You have selected the STUDENT OFFER! You have received extra luggage priveliges and a discount of Rs.500 per pax!\n";
amt=amt-num*500;
luggage=1;
}
else if(offer==2)
{
cout<<"You have selected the DEFENCE PERSONNEL OFFER! You have received a FREE MEAL and an upgrade to BUSINESS CLASS!\n";
meal=1;
fclass=2;
}
else if(offer==3)
{
cout<<"You are a FIRST TIME flySRM CUSTOMER! Please enjoy a FREE MEAL from our side and a discount of flat Rs.1000!\n";
meal=1;
amt=amt-1000;
}
else if(offer==4)
{
cout<<"You have selected the ELDERS OFFER! Please enjoy the comfort of BUSINESS CLASS and a discount of flat Rs.1500!\n";
fclass=2;
amt=amt-1500;
}
else if(ff==1)
{
cout<<"Thank you for trusting flySRM! You have received a free upgrade to BUSINESS CLASS on the house!\n";
fclass=2;
}
cout<<"Please pay Rs."<<amt<<" through any method like debit card, credit card or UPI in the next 5 minutes.";
cout<<"\n\nThank you for booking your flight with flySRM! Looking forward to seeing you in the skies with us!";
cout<<"\n\nDo you want to see a summary of your booking?";
cout<<"\nPress 1 to see booking summary or any other to proceed to the main menu...";
int ch;
cin>>ch;
if(ch==1) //viewing it once after booking
view();
}
public: void view() //viewing booking details
{
if(booking==1)
{
cout<<"Your booking\n\n";
cout<<"From: "<<from;
cout<<"\nTo: "<<to;
cout<<"\nDate of Departure: "<<day<<" / "<<month<<" / "<<year;
cout<<"\nClass: ";
if(fclass==1)
cout<<"Executive";
else if(fclass==2)
cout<<"Business";
else
cout<<"Economy";
cout<<"\nNumber of Passengers: "<<num;
cout<<"\nMeal: ";
if(meal==1)
cout<<"YES";
else
cout<<"NO";
cout<<"\nExtra Luggage: ";
if(luggage==1)
cout<<"YES";
else
cout<<"NO";
cout<<"\nAmount: Rs."<<amt;
cout<<"\nYour Feedback: "<<feedback;
cout<<"\n\nSeats are assigned on a first come-first serve basis for free.";
cout<<"\n\nExtra luggage and meal costs will be assigned at the check-in counter if applicable.";
}
else
{
cout<<"\nYou don't have an active booking with us right now!";
cout<<"\nDo you want to book a flight? Press 1 for YES, any other key for NO: ";
int ch;
cin>>ch;
if(ch==1)
book();
}
}
public: void edit() //editing global variables if required
{
cout<<"\nWhat do you want to edit?";
cout<<"\n1) Date\n2) Class\n3) Meal\n4) Luggage\n5) Offer\n\nUse the codes to select or press any other key to go back to the main menu: ";
int ch;
cin>>ch;
switch(ch)
{
case 1:
cout<<"\nEnter the new Date: ";
cin>>day>>month>>year;
if(day<0 || month<0 || year<0 || (month==2 && day>29) || ((month==4 || month==6 || month==9 || month==11) && day>30) || day>31)
{
cout<<"Invalid date entered! Please try again from the main menu!\n";
return;
}
cout<<"Since you changed the date, an extra fee of Rs.750 has been applied per pax\n";
amt=amt+num*750;
date_fee=750;
break;
case 2:
cout<<"\nWhich class do you want to fly?";
cout<<"\n1) Executive\n2) Business\nOther) Economy\n\nEnter your choice by entering the code: ";
cin>>fclass;
break;
case 3:
cout<<"\nDo you want to book a meal? Press 1 to select YES, any other key for NO: ";
cin>>meal;
break;
case 4:
cout<<"\nDo you want extra luggage weight? Press 1 to select YES, any other key for NO: ";
cin>>luggage;
break;
case 5:
if(fclass==1)
amt=num*10000;
else if(fclass==2)
amt=num*7500;
else
amt=num*5000;
cout<<"We have some special offers for you! Select ONE that is applicable with the given codes, or press any other key to proceed";
cout<<"\n1) Student Offer\n2) Defence Personnel Offer\n3) First Time flySRM Customer Offer\n4) Elders Offer\nEnter your choice: ";
cin>>offer;
if(offer==1)
{
cout<<"You have selected the STUDENT OFFER! You have received extra luggage priveliges and a discount of Rs.500 per pax!";
amt=amt-num*500;
luggage=1;
}
else if(offer==2)
{
cout<<"You have selected the DEFENCE PERSONNEL OFFER! You have received a FREE MEAL and an upgrade to BUSINESS CLASS!";
meal=1;
fclass=2;
}
else if(offer==3)
{
cout<<"You are a FIRST TIME flySRM CUSTOMER! Please enjoy a FREE MEAL from our side and a discount of flat Rs.1000!";
meal=1;
amt=amt-1000;
}
else if(offer==4)
{
cout<<"You have selected the ELDERS OFFER! Please enjoy the comfort of BUSINESS CLASS and a discount of flat Rs.1500!";
fclass=2;
amt=amt-1500;
}
else if(ff==1)
{
cout<<"Thank you for trusting flySRM! You have received a free upgrade to BUSINESS CLASS on the house!";
fclass=2;
}
amt+=date_fee;
break;
cout<<"Please pay Rs."<<amt<<" through any method like debit card, credit card or UPI in the next 5 minutes.";
cout<<"\n\nThank you for booking your flight with flySRM! Looking forward to seeing you in the skies with us!";
cout<<"\n\nDo you want to see a summary of your updated booking?";
cout<<"\nPress 1 to see booking summary or any other to proceed to the main menu...";
int ch;
cin>>ch;
if(ch==1)
view();
}
}
public: void cancel() //cancelling the booking
{
cout<<"\nDo you want to cancel the booking made for "<<num<<" pax on "<<day<<" / "<<month<<" / "<<year<<" from "<<from<<" to "<<to<<"?";
cout<<"\nPress 1 to CANCEL THE BOOKING, or any other key to proceed to the main menu: ";
int ch;
cin>>ch;
if(ch==1)
{
cout<<"You have cancelled the booking :-<\nSee you soon on flySRM!\n";
booking=0;
}
}
public: void customer_feedback()
{
cout<<"Please enter your feedback here: ";
cin>>feedback;
cout<<"Thank you for giving us for valuable feedback!\n";
}
};
int main() //main function to call other functions
{
int i=1, ch;
flySRM obj; //class object to call functions
while(i!=0) //will run as long as you enter a non-menu value
{
cout<<"WELCOME TO THE flySRM EASY TICKET BOOKING SYSTEM!";
cout<<"\n\nHow can we help you today?\n\nI want to";
cout<<"\n1) Book a Flight...";
cout<<"\n2) View my Booking...";
cout<<"\n3) Edit my Booking...";
cout<<"\n4) Cancel my Booking...";
cout<<"\n5) Give Feedback for flySRM...";
cout<<"\n\nPress the numbers to select an option, or press any other key to exit: ";
cin>>ch;
switch(ch) //simple switch case to pick the function to be called
{
case 1:
obj.book();
break;
case 2:
obj.view();
break;
case 3:
obj.edit();
break;
case 4:
obj.cancel();
break;
case 5:
obj.customer_feedback();
break;
default:
i=0;
break;
}
}
cout<<"\n\nThank you for considering flySRM! See you soon!";
}