-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovie Ticket Booking System.cpp
320 lines (315 loc) · 10.2 KB
/
Movie Ticket Booking System.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#include<iostream>
#include<string>
#include<map>
#include<unordered_map>
using namespace std;
int main(){
int option;
unordered_map <int, unordered_map <string, unordered_map <string, string> > > booking_hist;
map<string,int>free_seats;
map<string,int>movies_price;
free_seats["Avengers Endgame"]=300;
free_seats["The Witcher"]=300;
free_seats["Twilight Saga"]=300;
free_seats["KGF Chapter 2"]=300;
movies_price["Avengers Endgame"]=300;
movies_price["The Witcher"]=350;
movies_price["Twilight Saga"]=250;
movies_price["KGF Chapter 2"]=300;
p1:
cout<<"-------------------------------------------------\n";
cout<<"WELCOME TO MAXCINEMA MOVIE TICKET BOOKING SYSTEM\n";
cout<<"-------------------------------------------------\n";
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
cout<<" Movies Ticket Prices\n";
cout<<"Avengers Endgame"<<" "<<movies_price["Avengers Endgame"]<<"\n";
cout<<"The Witcher"<<" "<<movies_price["The Witcher"]<<"\n";
cout<<"Twilight Saga"<<" "<<movies_price["Twilight Saga"]<<"\n";
cout<<"KGF Chapter 2"<<" "<<movies_price["KGF Chapter 2"]<<"\n";
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
cout<<"-------------------------------------------------\n";
cout<<"Please Choose any Option from Below Menu: \n";
cout<<"------------------------------------------------\n"
"1 >> Book Movie Tickets.\n2 >> Cancel Movie Ticket.\n3 >> Print your Ticket.\n"
"4 >> Change Ticket Price(For Admin).\n5 >> View All Booking Records(For Admin).\n"
"6 >> Exit.\n---------------------------------------------------\n>>";
cin>>option;
if (option == 1){
int movie_opt;
p2:
cout<<"############################################\n";
cout<<"Choose your Movie from the Below Options:\n";
cout<<"--------------------------------------------\n"
"1 >> Avengers Endgame(Hin/Eng).\n2 >> The Witcher(Hin/Eng).\n"
"3 >> Twilight Saga(Hin/Eng).\n4 >> KGF Chapter 2(Hindi).\n"
"5 >> Move to Main Menu.\n>>";
cin>>movie_opt;
if (movie_opt==1 or movie_opt==2 or movie_opt==3 or movie_opt==4){
int lang, seats, av_seats, re_seats, confirm_ticket;
long long int c_num;
string name;
string lang_sel = "None";
string sel_movie_name = "None";
switch(movie_opt){
case 1:
sel_movie_name="Avengers Endgame";
av_seats = free_seats["Avengers Endgame"];
re_seats = 300 - av_seats;
break;
case 2:
sel_movie_name="The Witcher";
av_seats = free_seats["The Witcher"];
re_seats = 300 - av_seats;
break;
case 3:
sel_movie_name="Twilight Saga";
av_seats = free_seats["Twilight Saga"];
re_seats = 300 - av_seats;
break;
case 4:
sel_movie_name="KGF Chapter 2";
av_seats = free_seats["KGF Chapter 2"];
re_seats = 300 - av_seats;
break;
}
p3:
cout<<"--------------------------------------------\n";
cout<<"You Opted for "<<sel_movie_name<<"\n";
cout<<"--------------------------------------------\nPlease Choose the Language:\n"
"1 >> English.\n2 >> Hindi.\n>>";
cin>>lang;
if (lang==1){
lang_sel="English";
}
else if (lang==2){
lang_sel="Hindi";
}
if (lang==1 or lang==2){
cout<<"--------------------------------------------\n";
cout<<"You opted for "<< lang_sel<< " language.\n";
p4:
cout<<"-------------------------------------------\n"
"#Available Seats: "<<av_seats<<" #Reserverd Seats: "<<re_seats<<"\n";
cout<<"Please Enter Number of Seats to Book:\n>>";
cin>>seats;
if (seats>av_seats){
cout<<"Number of Seats Should be less then "<<av_seats<<" Try Again.";
goto p4;
}
else if (seats<=0){
cout<<"Number of Seats Should be More then 0! Try Again.";
goto p4;
}
else if (seats<av_seats or seats>0) {
cout<<"--------------------------------------------\n";
cout<<"You opted for "<<seats<<" Seats.\n";
cout<<"-------------------------------------------\n";
cout<<"Please Enter your Name >> ";
cin.ignore();
getline (cin,name);
cout<<"Please Enter your Contact Number >> ";
cin>>c_num;
cout<<"--------------------------------------------\n";
cout<<"Please Verify your Ticket Detials\n";
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"
" Movie: "<<sel_movie_name<<"\n"
" Tickets Booked By: "<<name<<"\n"
" Language: "<<lang_sel<<" \n"
" Number of Seats: "<<seats<<" \n"
" Contact Number : "<<c_num<<"\n"
" Total Bill : "<<movies_price[sel_movie_name]*seats<<"\n"
"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
p5:
cout<<"Do you Want to Book the Ticket ?\n"
"1 >> Yes\n2 >> No\n>>";
cin>>confirm_ticket;
if (confirm_ticket==1){
booking_hist[c_num][sel_movie_name]["Movie"]=sel_movie_name;
booking_hist[c_num][sel_movie_name]["Tickets Booked By"]=name;
booking_hist[c_num][sel_movie_name]["Language"]=lang_sel;
booking_hist[c_num][sel_movie_name]["Total Seats"]=to_string(seats);
booking_hist[c_num][sel_movie_name]["Contact Number"]=to_string(c_num);
booking_hist[c_num][sel_movie_name]["Total Bill"]=to_string(movies_price[sel_movie_name]*seats);
free_seats[sel_movie_name]=av_seats-seats;
cout<<"--------------------------------------------\n";
cout<<"TICKETS BOOKED SUCCESSFULLY!\n";
goto p1;
}
else if(confirm_ticket==2){
cout<<"TICKETS BOOKING CANCELLED!";
goto p1;
}
else{
cout<<"Please Choose a Valid Option!";
goto p5;
}
}
else{
goto p3;
}
}
else{
cout<<"Please Choose a Valid Option!\n";
goto p3;
}
}
else{
cout<<"Please Choose a Valid Option!\n";
goto p2;
}
}
else if (option == 2){
long long int usr_c_num;
int count = 0;
int temp = 0;
map<int, string> t_list ;
cout<<"Please Enter your Registered Phone Number, to check List your Tickets .\n"
">>";
cin>>usr_c_num;
for (auto i : booking_hist[usr_c_num]){
temp=1;
count=count+1;
cout<<"Ticket No : "<<count<<"\n";
t_list[count] = i.first;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
for (auto j : booking_hist[usr_c_num][i.first]){
cout << j.first << " : " << j.second << endl;
}
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
}
if (count>0){
int t_no;
cout<<"Please Enter Ticket Number to Cancel from above list.\n>>";
cin>>t_no;
if (t_no<count or t_no>=0){
booking_hist[usr_c_num].erase(t_list[t_no]);
cout<<"Ticket Number "<<t_no<<" for Movie "<<t_list[t_no]<<" Cancelled Successfully.\n";
}
}
if (temp == 0){
cout<<"--------------------------------------------\n";
cout<<"NO TICKETS FOUND WITH CONTACT NUMBER "<<usr_c_num<<"\n";
}
goto p1;
}
else if(option == 3){
long long int usr_c_num;
int temp=0;
cout<<"Please Enter your Registered Phone Number, to check your Ticket Status.\n"
">>";
cin>>usr_c_num;
for (auto i : booking_hist[usr_c_num]){
temp=1;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
for (auto j : booking_hist[usr_c_num][i.first]){
cout << j.first << " : " << j.second << endl;
}
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
}
if (temp == 0){
cout<<"--------------------------------------------\n";
cout<<"NO TICKETS FOUND WITH CONTACT NUMBER "<<usr_c_num<<"\n";
}
goto p1;
}
else if (option == 4) {
string pass;
int ch_tp,new_pr;
p7:
int count = 1;
cout << "Please Enter Admin Password to Continue.\n>>";
cin >> pass;
if (pass=="admin"){
cout<<"Please Choose Movie from Below Menu to change its Ticket Price. \n";
cout<<"--------------------------------------------\n"
"1 >> Avengers Endgame(Hin/Eng).\n2 >> The Witcher(Hin/Eng).\n"
"3 >> Twilight Saga(Hin/Eng).\n4 >> KGF Chapter 2(Hindi).\n"
"5 >> Move to Main Menu.\n>>";
cin>>ch_tp;
switch(ch_tp){
case 1:
cout<<"Please Enter new Ticket Price.\n>>";
cin>>new_pr;
movies_price["Avengers Endgame"]=new_pr;
cout<<"Price Changed Successfully to "<<new_pr<<"\n";
goto p1;
break;
case 2:
cout<<"Please Enter new Ticket Price.\n>>";
cin>>new_pr;
movies_price["The Witcher"]=new_pr;
cout<<"Price Changed Successfully to "<<new_pr<<"\n";
goto p1;
break;
case 3:
cout<<"Please Enter new Ticket Price.\n>>";
cin>>new_pr;
movies_price["Twilight Saga"]=new_pr;
cout<<"Price Changed Successfully to "<<new_pr<<"\n";
goto p1;
break;
case 4:
cout<<"Please Enter new Ticket Price.\n>>";
cin>>new_pr;
movies_price["KGF Chapter 2"]=new_pr;
cout<<"Price Changed Successfully to "<<new_pr<<"\n";
goto p1;
break;
}
}
else{
int ad_login;
cout<<"Invalid Password Please try again!\n"
"1) Move to Main Menu.\n2) Try again.";
cin>>ad_login;
if (ad_login==2){
goto p7;
}
else {
goto p1;
}
}
}
else if (option == 5) {
p6:
string pass;
int temp = 0;
int count = 1;
cout << "Please Enter Admin Password to Continue.\n>>";
cin >> pass;
if (pass=="admin"){
for (auto i : booking_hist){
temp = 1;
for (auto j : booking_hist[i.first]){
cout<<"Ticket "<<count<<"\n";
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
for (auto k : booking_hist[i.first][j.first]){
cout << k.first << " : " << k.second << endl;
}
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n";
count = count +1;
}
}
if (temp == 0){
cout<<"NO RECORDS FOUND!\n";
}
goto p1;
}
else{
int ad_login;
cout<<"Invalid Password Please try again!\n"
"1) Move to Main Menu.\n2) Try again.";
cin>>ad_login;
if (ad_login==2){
goto p6;
}
else {
goto p1;
}
}
}
else{
cout<<"Please Choose a Valid Option!";
goto p1;
}
}