forked from risu9892/Railway-Ticket-Booking-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponents.cpp
56 lines (40 loc) · 1.35 KB
/
components.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
// g++ test.cpp -o test && ./test
#include "components.cpp"
int book(deque<int> avl_seats){
int tno = TICKETS.ticket_counter;
ticket tkt = TICKETS.tickets[tno];
int trid = tkt.train_no/13 - 1369;
int alloted_seat;
tkt.amount = (STATIONS.Stations[tkt.from].km - STATIONS.Stations[tkt.to].km)*13;
if(tkt.tr_start_DorP == 'd'){
for(int i = 0; i < tkt.psgr_count; i++){
if(tkt.psgrs[i].age >= 60 || tkt.psgrs[i].gender == 'f' || tkt.psgrs[i].gender == 'F'){
alloted_seat = avl_seats.front();
avl_seats.pop_front();
}
else{
alloted_seat = avl_seats.back();
avl_seats.pop_back();
}
markD(tkt.from, tkt.to, trid, alloted_seat);
}
}
else{
for(int i = 0; i < tkt.psgr_count; i++){
if(tkt.psgrs[i].age >= 60 || tkt.psgrs[i].gender == 'f' || tkt.psgrs[i].gender == 'F'){
alloted_seat = avl_seats.front();
avl_seats.pop_front();
}
else{
alloted_seat = avl_seats.back();
avl_seats.pop_back();
}
markP(tkt.from, tkt.to, trid, alloted_seat);
}
}
TICKETS.tickets[tno] = tkt;
return TICKETS.ticket_counter++;
}
int main(){
load_data();
}