-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
141 lines (138 loc) · 3.98 KB
/
main.c
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
#include <stdio.h>
#include <stdlib.h>
#include "conio2.h"
#include "rlyres.h"
int main()
{
add_trains();
int choice;
char *ptrain_no;
char *pmob_no;
int *pticket_no;
int *ptr;
int value;
while(1)
{ int ticket_no;
Passenger* ptr;
char train_no[20];
choice=enterchoice();
if(choice==9)
exit(0);
switch(choice)
{
case 1:
view_trains();
break;
case 2:
clrscr();
ptr=get_passenger_details();
clrscr();
if(ptr!=NULL)
{
ticket_no=book_ticket(*ptr);
if(ticket_no==-1)
{
textcolor(LIGHTRED);
printf("Booking Failed!!");
textcolor(WHITE);
printf("\n\n\nPress any key to go back to main screen");
getch();
clrscr();
}
if(ticket_no!=-1)
{
textcolor(YELLOW);
printf("Booking Successful!!\n");
textcolor(LIGHTGREEN);
printf("Your Ticket No is %d",ticket_no);
textcolor(YELLOW);
printf("\nHappy Journey!!");
textcolor(WHITE);
printf("\n\n\nPress any key to go back to main screen");
getch();
clrscr();
}
}
break;
case 3:
clrscr();
ticket_no=accept_ticket_no();
if(ticket_no!=0)
view_ticket(ticket_no);
getch();
clrscr();
break;
case 4:
clrscr();
pmob_no=accept_mob_no();
if(pmob_no!=NULL)
{
ptr=get_ticket_no(pmob_no);
view_all_tickets(pmob_no,ptr);
}
getch();
clrscr();
break;
case 5:
clrscr();
view_all_bookings();
getch();
clrscr();
break;
case 6:
clrscr();
printf("Enter train no to see all bookings of train:");
scanf("%s",train_no);
view_bookings(train_no);
getch();
clrscr();
break;
case 7:
clrscr();
ticket_no=accept_ticket_no();
if(ticket_no!=0)
value=cancel_ticket(ticket_no);
if(value==0)
{
textcolor(LIGHTRED);
printf("Sorry!No tickets booked against the ticket number %d",ticket_no);
}
else
{
textcolor(LIGHTGREEN);
printf("Ticket number %d successfully cancelled!!",ticket_no);
}
textcolor(WHITE);
printf("\n\n\nPress any key to go back to main screen");
getch();
clrscr();
break;
case 8:
clrscr();
ptrain_no=accept_train_no();
if(ptrain_no!=NULL)
value=cancel_train(ptrain_no);
if(value==0)
{
textcolor(LIGHTRED);
printf("Sorry!No tickets booked in the train number %s",ptrain_no);
}
else
{
textcolor(LIGHTGREEN);
printf("Train number %s successfully cancelled!!",ptrain_no);
}
textcolor(WHITE);
printf("\n\n\nPress any key to go back to main screen");
getch();
clrscr();
break;
default:
textcolor(LIGHTRED);
printf("Wrong Choice!Try again\n");
getch();
clrscr();
}
}
return 0;
}