-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntryQueueManager_main.cpp
More file actions
193 lines (185 loc) · 6.04 KB
/
EntryQueueManager_main.cpp
File metadata and controls
193 lines (185 loc) · 6.04 KB
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
#include"EntryQueueManager_class.cpp"
int main()
{
int capacity, gates, poptime, time_of_entry, VG, capacity_vip;
cout << "Enter the capacity of your stadium: ";
cin >> capacity;
cout << "Enter the capacity of VIP people in your stadium: ";
cin >> capacity_vip;
cout << "Enter the no of gates to be used for entering the people in the stadium: ";
cin >> gates;
cout << "Enter the number of vip gates used for entering the people in the stadium: ";
cin >> VG;
cout << "Enter the time required for the pop in mins : ";
cin >> poptime;
cout << "Enter the amount of time(in min) for which the entry gates should be open: ";
cin >> time_of_entry;
int max_time = time_of_entry / poptime;
capacity = capacity - capacity_vip;
gates = gates - VG;
EntryQueueManager e(capacity, gates, VG, capacity_vip);
e.RandomAssignment();
e.RandomAssignmentVip();
e.display();
int remaining, remainingV;
int remaining_total_V = capacity_vip / 2;
int remaining_total = capacity / 2;
cout << "Are you a VIP c ? " << endl
<< "Enter 0 if Yes and 1 if No : ";
int c;
cin >> c;
if (c == 0)
{
remaining = capacity / 2;
remainingV = capacity_vip / 2 - 1;
}
else if (c == 1)
{
remaining = capacity / 2 - 1;
remainingV = capacity_vip / 2;
}
else
{
cout << "Enter correct value";
return 0;
}
int timef;
int a = 0;
int b = 0;
while ((remaining_total != 0 || remaining_total_V != 0) && a != max_time)
{
int num;
cout << "Enter 0 to note the people entering else enter any other number : ";
cin >> num;
switch (num)
{
case 0:
{
cout << "Enter 0 if want to enter any queue : " << endl
<< "Enter 1 if you want to shift : " << endl
<< "Enter any other number to continue using the app :";
int num1;
cin >> num1;
if (num1 == 0)
{
cout << "Enter the number of people accompanying you : ";
int group;
cin >> group;
group++;
if (c == 0)
{
if (group == 1)
{
int moving_queue = e.InsertNewVip(1, b);
remaining_total_V--;
cout << "You have to move to queue " << moving_queue << endl;
}
else
{
b = group;
int moving_queue = e.InsertNewVip(1, b);
remaining_total_V -= b;
remainingV =remainingV- b+1;
cout << "You all have to move to VIPqueue " << moving_queue << endl;
}
}
else
{
if (group == 1)
{
int moving_queue = e.InsertNew(1, b);
remaining_total--;
cout << "You have to move to queue " << moving_queue << endl;
}
else
{
b = group;
int moving_queue = e.InsertNew(1, b);
remaining_total -= b;
remaining =remaining - b+1;
cout << "You all have to move to queue " << moving_queue << endl;
}
}
}
else if (num1 == 1)
{
cout << "Enter the number of people accompanying you : ";
int group;
cin >> group;
group++;
if (c == 0)
{
}
else
{
if (group == 1)
{
int queue_person, standing;
cout << "Enter your queue number : ";
cin >> queue_person;
cout << "Enter your standing number in the queue : ";
cin >> standing;
e.shift1(queue_person, standing, poptime, b);
}
else
{
b = group;
int queue_person, standing;
cout << "Enter your queue number : ";
cin >> queue_person;
cout << "Enter the standing of last person of your group in the queue : ";
cin >> standing;
e.shift1(queue_person, standing, poptime, b);
}
}
}
else
{
cout << "---" << remainingV << endl;
int peopleV = e.RandomAssignment2V(remainingV);
cout << peopleV << endl;
cout << "RV:" << remainingV << endl;
cout<<"RVT: "<<remaining_total_V<<endl;
e.InsertNewVip(peopleV, b);
remainingV = remainingV - peopleV;
remaining_total_V = remaining_total_V - peopleV;
int people = e.RandomAssignment2(remaining);
cout << people << endl;
cout << "R:" << remaining;
cout << "RT:" << remaining_total;
e.InsertNew(people, b);
remaining = remaining - people;
remaining_total = remaining_total - people;
}
b = 0;
}
default:
{
e.shift();
e.shiftV();
e.pop();
e.popV();
a++;
e.display();
}
}
}
timef = a * poptime;
cout << timef << endl;
cout << "No new Entry allowed now for entering the line" << endl;
a = 0;
remaining = e.people_in_queue();
cout << remaining;
if (remaining != 0)
{
while (remaining != 0)
{
e.shift();
e.pop();
a++;
remaining = e.people_in_queue();
}
}
timef += a * poptime;
cout << "Total time required for the people to enter is : " << timef << endl;
}