-
Notifications
You must be signed in to change notification settings - Fork 0
/
aakashtravels.cpp
935 lines (807 loc) · 23.1 KB
/
aakashtravels.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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
// Basic header files required for different inbuilt function
#include <iostream>
#include <fstream>
#include <conio.h>
#include <random>
#include <iomanip>
using namespace std;
// Here class bus is defined that makes easier to implement different methods
class Bus
{
string destination;
string origin;
string driverFirstName;
string driverLastName;
int busNumber;
string departureTime;
int year;
int month;
int day;
int fare;
int seats[8][4] = { 0 };
string firstName;
string lastName;
int seatNumber;
int ticketNumber;
long long phoneNumber;
ofstream busFileOut, passFileOut;
ifstream busFileIn, passFileIn;
// Public access functions for class Bus
public:
void inputInfo();
void removeInfo();
void seatInfo();
void passenger();
void admin();
void bookTicket();
void cancelReservation();
void showTicket();
bool fileHandling(int);
void adminCheck();
};
void vline(char ch, int n)
{
for (int i = n; i > 0; i--)
{
cout << ch;
}
cout << endl;
}
void headerDisplay() {
cout << R"(
_______ _ _ _______ _
(_______) | | | | (_______) | |
_______ _____| | _ _____ ___| |__ _ ____ _____ _ _ _____| | ___
| ___ (____ | |_/ |____ |/___) _ \ | |/ ___|____ | | | | ___ | | /___)
| | | / ___ | _ (/ ___ |___ | | | | | | | / ___ |\ V /| ____| ||___ |
|_| |_\_____|_| \_)_____(___/|_| |_| |_|_| \_____| \_/ |_____)\_|___/
)";
vline('-', 120);
}
// This function will run if there are no bus in the system and user try to access bus info
void emptyList()
{
cout << setw(65) << "The list is empty" << endl;
vline('-', 120);
}
// Function to input and check the password for admin access
void inputPassword()
{
string password, pass;
fstream passFile;
passFile.open("password.bin", ios::app | ios:: in);
if (passFile.peek() == ifstream::traits_type::eof())
{
pass = "admin123";
passFile << pass;
}
passFile >> pass;
passFile.close();
do {
cout << "Enter password: ";
char ch = _getch();
while (ch != 13)
{
// 13 is the ASCII code for the Enter key
if (ch == 8)
{
// 8 is the ASCII code for the backspace key
if (!password.empty())
{
cout << '\b' << ' ' << '\b';
password.pop_back();
}
}
else
{
password.push_back(ch);
cout << '*';
}
ch = _getch();
}
if (password != pass)
{
cout << "\nERROR! Incorrect Password" << endl;
vline('-', 120);
password.clear();
}
} while (password != pass);
cout << endl;
}
void changePassword()
{
fstream passFile;
string password;
inputPassword();
Bus b;
cout << "Enter new password: ";
cin >> password;
passFile.open("password.bin", ios::trunc | ios::out);
passFile << password;
passFile.close();
vline('-', 120);
cout << "SUCCESS! Password Changed" << endl;
vline('-', 120);
return b.admin();
}
// Function to check if the bus number entered exists in the system
bool Bus::fileHandling(int n)
{
int countVar = 0, table = 0, q = 0;
Bus bus, pass;
bool empty = false;
if (n <= 5)
{
busFileIn.open("bus_info.bin", ios::out);
if (busFileIn.peek() == ifstream::traits_type::eof())
{
return false;
}
busFileIn.clear();
busFileIn.seekg(0);
while (busFileIn >> bus.destination >> bus.origin >> bus.driverFirstName >> bus.driverLastName >> bus.busNumber >> bus.year >> bus.month >> bus.day >> bus.departureTime >> bus.fare)
{
bool showInfo = false;
if (busNumber == bus.busNumber && n == 1)
{
countVar++;
}
if (destination == bus.destination && (n == 2 || n == 4))
{
countVar++;
if (n == 4)
{
showInfo = true;
}
}
if (n == 5)
{
showInfo = true;
}
if (showInfo == true)
{
bool seatExists = false;
int availableSeats = 0;
for (int i = 1; i <= 32; i++)
{
bus.seatNumber = i;
seatExists = bus.fileHandling(7);
if (seatExists == false)
{
availableSeats++;
}
}
if (table == 0)
{
cout << "\033c";
headerDisplay();
cout << setw(5) << "S.No" << setw(16) << "Bus Number" << setw(19) << "From - To" << setw(26) << "Departure Date" << setw(19) << "Departure Time" << setw(10) << "Fare" << setw(23) << "Seats Available" << endl;
vline('=', 120);
table++;
}
cout << setw(3) << ++q << setw(14) << bus.busNumber << setw(18) << bus.origin << " - " << bus.destination << setw(20 - bus.destination.length()) << bus.year << "/" << setw(2) << setfill('0') << bus.month << "/" << setw(2) << setfill('0') << bus.day << setfill(' ') << setw(17) << bus.departureTime << setw(12) << "Rs " << bus.fare << setw(16) << availableSeats << endl;
vline('-', 120);
countVar++;
}
if (n == 3 && destination == bus.destination && busNumber == bus.busNumber)
{
countVar++;
}
}
busFileIn.close();
if (countVar != 0)
{
return true;
}
return false;
}
else
{
passFileIn.open("passengerInfo.bin");
passFileIn.clear();
passFileIn.seekg(0);
while (passFileIn >> pass.firstName >> pass.lastName >> pass.ticketNumber >> pass.seatNumber >> pass.phoneNumber >> pass.busNumber)
{
bool showInfo = false;
if (ticketNumber == pass.ticketNumber && n == 6)
{
countVar++;
}
if (seatNumber == pass.seatNumber && busNumber == pass.busNumber && n == 7)
{
countVar++;
}
if (busNumber == pass.busNumber && (n == 8 || n == 9))
{
seats[(pass.seatNumber - 1) / 4][(pass.seatNumber - 1) % 4] = 1;
countVar++;
if (n == 9)
{
showInfo = true;
}
}
if (showInfo == true)
{
if (table == 0)
{
cout << "\033c";
headerDisplay();
cout << setw(10) << "S.No" << setw(28) << "Passenger's Name" << setw(21) << "Seatnumber" << setw(25) << "Ticketnumber" << setw(23) << "Phonenumber" << endl;
vline('=', 120);
table++;
}
cout << setw(5);
cout << setw(9) << ++q << setw(20) << pass.firstName << " " << pass.lastName << setw(25 - pass.lastName.length()) << pass.seatNumber << setw(25) << pass.ticketNumber << setw(27) << pass.phoneNumber << endl;
vline('-', 120);
}
}
passFileIn.close();
if (countVar != 0)
{
return true;
}
return false;
}
}
void Bus::adminCheck()
{
Bus b;
string choice;
bool busNumberExists = false;
system("cls");
headerDisplay();
do {
cout << "Enter the bus number: ";
cin >> b.busNumber;
busNumberExists = b.fileHandling(1);
if (busNumberExists == false)
{
cout << "ERROR! The bus of number " << b.busNumber << " doesnot exists" << endl;
}
}
while (busNumberExists == false);
b.fileHandling(8);
b.seatInfo();
cout << "Would you like to see details of passengers of this bus? (Y/N)" << endl;
do {
cout << "Your choice: ";
cin >> choice;
if (choice == "y" || choice == "Y")
{
b.fileHandling(9);
}
else if (choice == "n" || choice == "N")
{
return admin();
}
else
{
cout << "ERROR! Please enter Y or y for yes or N or n for no" << endl;
}
} while (choice != "n" && choice != "N" && choice != "y" && choice != "Y");
}
// This function shows the seats of the bus and shows whether they are booked or not
void Bus::seatInfo()
{
vline('-', 120);
int q = 0;
fileHandling(7);
cout << endl;
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 4; j++)
{
cout.width(10);
if (j == 2)
{
cout.width(20);
}
if (seats[i][j] == 1)
{
cout << ++q << ".!RESERVED";
}
else
{
cout << ++q << ".!!Empty!!";
}
}
cout << endl << endl;
}
vline('-', 120);
}
// This function reserves a seat for the passenger in the bus
void Bus::bookTicket()
{
vline('-', 120);
passFileOut.open("passengerInfo.bin", ios::app);
int i, row, col;
bool reserved = false;
bool busNumberExists = false;
bool destinationExists = false;
Bus bus, pass;
string phone;
system("cls");
headerDisplay();
cout << "Please enter the desired destination: ";
cin >> pass.destination;
destinationExists = pass.fileHandling(4);
if (destinationExists == false)
{
system("cls");
headerDisplay();
cout << "ERROR! No buses are available for given destination" << endl;
vline('-',120);
return passenger();
}
do {
vline('-', 120);
cout << "Enter bus number: ";
cin >> pass.busNumber;
busNumberExists = pass.fileHandling(3);
if (busNumberExists == false || destinationExists == false)
{
cout << "ERROR! Bus number " << pass.busNumber << " is not available for provided destination" << endl;
vline('-',120);
}
} while (busNumberExists == false || destinationExists == false);
pass.fileHandling(8);
pass.seatInfo();
do {
vline('-', 120);
cout << "Enter seat number: ";
cin >> pass.seatNumber;
reserved = pass.fileHandling(7);
if (reserved == true)
{
cout << "ERROR! The seat is already reserved" << endl;
vline('-', 120);
}
else if (pass.seatNumber > 32)
{
cout << "ERROR! The seat limit is 32. So, please enter seat number upto 32" << endl;
vline('-', 120);
}
else
{
break;
}
} while (reserved == true || pass.seatNumber > 32);
row = (seatNumber - 1) / 4;
col = (seatNumber - 1) % 4;
cout << "Passenger's Details" << endl;
vline('-', 21);
cout << "Firstname: ";
getline(cin >> ws, pass.firstName);
cout << "Lastname: ";
getline(cin >> ws, pass.lastName);
do {
cout << "Enter passenger's phone number: ";
cin >> pass.phoneNumber;
phone = to_string(pass.phoneNumber);
if (phone.length() != 10)
{
cout << "ERROR! Please enter 10 digits number" << endl;
vline('-', 120);
cin.clear();
}
}
while (phone.length() != 10);
random_device rd;
mt19937 gen(rd());
uniform_int_distribution < > dis(1000, 10000);
pass.ticketNumber = dis(gen);
passFileOut << pass.firstName << " " << pass.lastName << " " << pass.ticketNumber << " " << pass.seatNumber << " " << pass.phoneNumber << " " << pass.busNumber << endl;
passFileOut.close();
vline('-', 120);
cout << "Your seat is reserved successfully" << endl;
vline('-', 120);
system("pause");
pass.showTicket();
}
void Bus::cancelReservation()
{
Bus pass1, pass2;
system("cls");
headerDisplay();
cout << "Enter ticket number: ";
cin >> pass1.ticketNumber;
bool ticketNumberExists = pass1.fileHandling(6);
if (ticketNumberExists == true)
{
passFileIn.open("passengerInfo.bin");
passFileOut.open("tempPass.bin");
passFileIn.clear();
passFileIn.seekg(0);
while (passFileIn >> pass2.firstName >> pass2.lastName >> pass2.ticketNumber >> pass2.seatNumber >> pass2.phoneNumber >> pass2.busNumber)
{
if (pass1.ticketNumber != pass2.ticketNumber)
{
passFileOut << pass2.firstName << " " << pass2.lastName << " " << pass2.ticketNumber << " " << pass2.seatNumber << " " << pass2.phoneNumber << " " << pass2.busNumber << endl;
}
}
passFileIn.close();
passFileOut.close();
remove("passengerInfo.bin");
rename("tempPass.bin", "passengerInfo.bin");
system("cls");
headerDisplay();
cout << "SUCCESS! The ticket is successfully cancelled" << endl;
vline('-', 120);
}
else
{
system("cls");
headerDisplay();
cout << "The ticket number " << pass1.ticketNumber << " is not found in the list" << endl;
vline('-', 120);
return passenger();
}
}
// This function gives the details about the seat and ticket
void Bus::showTicket()
{
passFileIn.open("passengerInfo.bin");
busFileIn.open("bus_info.bin");
Bus pass1, bus, pass2;
int n = 0;
passFileIn.clear();
passFileIn.seekg(0);
while (passFileIn >> pass2.firstName >> pass2.lastName >> pass2.ticketNumber >> pass2.seatNumber >> pass2.phoneNumber >> pass2.busNumber)
{
if (pass2.ticketNumber == ticketNumber)
{
n++;
break;
}
}
passFileIn.close();
if (n == 0)
{
system("cls");
headerDisplay();
cout << "ERROR! Ticket number not found" << endl;
vline('-', 120);
return passenger();
}
while (busFileIn >> bus.destination >> bus.origin >> bus.driverFirstName >> bus.driverLastName >> bus.busNumber >> bus.year >> bus.month >> bus.day >> bus.departureTime >> bus.fare)
{
if (pass2.busNumber == bus.busNumber)
{
break;
}
}
busFileIn.close();
cout << "\033c";
vline('=', 120);
cout << setw(65) << "BUS TICKET" << endl;
vline('-', 120);
cout << endl;
cout << setw(23) << "Passenger's Name: " << pass2.firstName << " " << pass2.lastName << setw(65 - pass2.lastName.length()) << "Ticket Number: " << pass2.ticketNumber << endl << endl;
cout << setw(21) << "Contact Number: " << pass2.phoneNumber << setw(65) << "Departure date: " << bus.year << "/" << bus.month << "/" << bus.day << endl << endl;
cout << setw(17) << "Bus Number: " << pass2.busNumber << setw(76) << "Departure Time: " << bus.departureTime << endl << endl;
cout << setw(18) << "Seat Number: " << pass2.seatNumber << setw(56) << endl << endl;
cout << setw(53) << "From: " << bus.origin << setw(5) << "To: " << bus.destination << endl;
cout << setw(97) << "Total Amount: Rs " << bus.fare << endl;
vline('-', 120);
cout << "NOTE: 1) Please note down your ticket number as it is required for further use" << endl << endl;
cout << " 2) Please report to the respective counter before an hour of departure otherwise your ticket will be cancelled" << endl;
vline('=', 120);
system("pause");
}
// This function removes a bus from the system
void Bus::removeInfo()
{
bool busNumberExists = false;
bool validChoice = false;
Bus bus1, bus2, pass;
string choice;
system("cls");
headerDisplay();
cout << "Enter the bus number: ";
cin >> bus1.busNumber;
busNumberExists = bus1.fileHandling(1);
if (busNumberExists == false)
{
system("cls");
headerDisplay();
cout << "ERROR! The bus number " << bus1.busNumber << " is not on the list" << endl;
vline('-', 120);
return admin();
}
busNumberExists = bus1.fileHandling(8);
if (busNumberExists == true)
{
system("cls");
headerDisplay();
cout << "ERROR! The passengers have already reserved seats of this bus. So, it cannot be deleted" << endl;
vline('-', 120);
return admin();
}
busFileIn.open("bus_info.bin");
busFileOut.open("tempBus.bin");
while (busFileIn >> bus2.destination >> bus2.origin >> bus2.driverFirstName >> bus2.driverLastName >> bus2.busNumber >> bus2.year >> bus2.month >> bus2.day >> bus2.departureTime >> bus2.fare)
{
if (bus1.busNumber != bus2.busNumber)
{
busFileOut << bus2.destination << " " << bus2.origin << " " << bus2.driverFirstName << " " << bus2.driverLastName << " " << bus2.busNumber << " " << bus2.year << " " << bus2.month << " " << bus2.day << " " << bus2.departureTime << " " << bus2.fare << endl;
}
}
busFileIn.close();
busFileOut.close();
remove("bus_info.bin");
rename("tempBus.bin", "bus_info.bin");
system("cls");
headerDisplay();
cout << "SUCCESS! The bus is deleted from the list successfully" << endl;
vline('-', 120);
}
void Bus::inputInfo()
{
bool busNumberExists = false;
Bus inBus;
system("cls");
headerDisplay();
busFileOut.open("bus_info.bin", ios::app);
do {
cout << "Enter the bus number: ";
cin >> inBus.busNumber;
busNumberExists = inBus.fileHandling(1);
if (busNumberExists == true)
{
cout << "ERROR! The bus number " << inBus.busNumber << " already exists" << endl;
vline('-', 120);
}
} while (busNumberExists == true);
vline('-', 16);
cout << "Driver Details" << endl;
vline('-', 16);
cout << "Firstname: ";
getline(cin >> ws, inBus.driverFirstName);
cout << "Lastname: ";
getline(cin >> ws, inBus.driverLastName);
vline('-', 16);
cout << "From: ";
getline(cin, inBus.origin);
cout << "To: ";
getline(cin, inBus.destination);
vline('-', 16);
cout << "Departure Information"<<endl;
vline('-', 16);
cout << "Year: ";
cin >> inBus.year;
cout << "Month: ";
cin >> inBus.month;
cout << "Day: ";
cin >> inBus.day;
cout << "Enter the departure time (hh:mm): ";
getline(cin >> ws, inBus.departureTime);
vline('-', 16);
cout << "Enter the fare: ";
cin >> inBus.fare;
busFileOut << inBus.destination << " " << inBus.origin << " " << inBus.driverFirstName << " " << inBus.driverLastName << " " << inBus.busNumber << " " << inBus.year << " " << inBus.month << " " << inBus.day << " " << inBus.departureTime << " " << inBus.fare << endl;
busFileOut.close();
}
// This function contains acions that can be performed by bus admin
void Bus::admin()
{
Bus b;
bool empty;
inputPassword();
system("cls");
headerDisplay();
cout<<R"(
+-------------------------------------------------------------------+
| |
| 1. Add a Bus |
| |
| 2. Delete a Bus |
| |
| 3. View Available Buses |
| |
| 4. Chect seat status |
| |
| 5. Change to Passenger mode |
| |
| 6. Change admin password |
| |
| 7. Exit |
| |
+-------------------------------------------------------------------+
)";
int option = 0;
cout << setw(45) << "Select an action: ";
do {
cin >> option;
if (cin.fail() == true)
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
} while (cin.fail() == true);
switch (option)
{
case 1:
b.inputInfo();
system("cls");
headerDisplay();
cout<<"SUCCESS! Bus added successfully"<<endl;
vline('-',120);
break;
case 2:
b.removeInfo();
break;
case 3:
empty = b.fileHandling(5);
if (empty == false)
{
cout<<empty<<endl;
system("cls");
headerDisplay();
emptyList();
}
system("pause");
system("cls");
headerDisplay();
break;
case 4:
b.adminCheck();
system("pause");
system("cls");
headerDisplay();
break;
case 5:
system("cls");
headerDisplay();
b.passenger();
break;
case 6:
system("cls");
headerDisplay();
changePassword();
break;
case 7:
cout << "Closing the program!!" << endl <<
"<Thank You :)>" << endl <<
"Created By Aakash Dhakal" << endl;
exit(0);
break;
default:
system("cls");
headerDisplay();
vline('-', 120);
cout << setw(80) << "ERROR! Please enter valid numbers from 1 to 6" << endl;
vline('-', 120);
return admin();
}
return admin();
}
// This function contains acions that can be performed by passenger
void Bus::passenger()
{
Bus b;
bool empty;
cout<<R"(
+-------------------------------------------------------------------+
| |
| 1. View Available Buses |
| |
| 2. Book a Ticket |
| |
| 3. View your Ticket |
| |
| 4. Cancel your Reservation |
| |
| 5. Change to Admin mode |
| |
| 6. Exit |
| |
+-------------------------------------------------------------------+
)";
int option = 0;
cout << setw(45) << "Select an action: ";
do {
cin >> option;
if (cin.fail() == true)
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
} while (cin.fail() == true);
switch (option)
{
case 1:
empty = b.fileHandling(5);
if (empty == false)
{
system("cls");
headerDisplay();
emptyList();
}
system("pause");
break;
case 2:
b.bookTicket();
system("cls");
headerDisplay();
break;
case 3:
system("cls");
headerDisplay();
cout << "Enter your ticket number: ";
cin >> b.ticketNumber;
b.showTicket();
system("cls");
headerDisplay();
break;
case 4:
b.cancelReservation();
break;
case 5:
system("cls");
headerDisplay();
b.admin();
break;
case 6:
cout << "Closing the program!!" << endl <<
"<Thank You :)>" << endl <<
"Created By Aakash Dhakal" << endl;
exit(0);
break;
default:
system("cls");
headerDisplay();
vline('-', 120);
cout << setw(80) << "ERROR! Please enter valid numbers from 1 to 6" << endl;
return passenger();
break;
}
return passenger();
vline('-', 120);
}
void programMode()
{
Bus b;
cout << setw(30) << " 1. Admin" << setw(30) << " 2. Passenger " << setw(25) << "3. Exit" << endl;
vline('-', 120);
int choice;
do {
cout << "Select program mode: ";
cin >> choice;
if (cin.fail() == true)
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
} while (cin.fail() == true);
switch (choice)
{
case 1:
system("cls");
headerDisplay();
b.admin();
break;
case 2:
system("cls");
headerDisplay();
b.passenger();
break;
case 3:
cout << "Closing the program!!" << endl <<
"<Thank You :)>" << endl <<
"Created By Aakash Dhakal" << endl;
exit(0);
default:
system("cls");
headerDisplay();
cout << setw(80) << "ERROR! Please enter valid numbers from 1 to 3" << endl;
vline('-', 120);
return programMode();
}
}
// This is the main function from where the program starts
int main(int argc, char** argv)
{
headerDisplay();
programMode();
return 0;
}