-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
263 lines (224 loc) · 7.21 KB
/
Copy pathmain.cpp
File metadata and controls
263 lines (224 loc) · 7.21 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
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
#include <iostream>
#include "Model/ListaDoblePreferencial.h"
#include "Model/ColaEspera.h"
#include "Model/PilaPasillo.h"
#include "Model/ListaGeneral.h"
Client CreateClient(){
string name;
string id;
cout << "What is your name" << endl;
cin >> name;
cout << "What is your Id" << endl;
cin >> id;
if(id.empty() || name.empty()){
cout << "You can reserve without personal information" << endl;
Client clientE = *new Client();
return clientE;
}
Client client = Client(name, id);
return client;
}
void addClientToLine(ColaEspera *cola, Client client){
cout << "There are not spots available, would you like to wait in line? (Yes/No)" << endl;
cout << "This is the line" << endl;
cola->showLine();
string answerLine;
cin >> answerLine;
if (!answerLine.empty() && (answerLine == "Yes" || answerLine == "yes" || answerLine == "YES") ){
cola->insertClient(client);
} else {
cout << "User was not added to the line" << endl;
}
}
void General(ListaGeneral *general, ColaEspera *colaGeneral){
Client client = CreateClient();
bool result = general->addClient(client);
if(result){
cout << "The reservation was successful" << endl;
}else{
addClientToLine(colaGeneral, client);
}
}
void Hall(PilaPasillo *pila, ColaEspera *colaPasillo){
Client client = CreateClient();
bool result = pila->push(client);
if(result){
cout << "The reservation was successful" << endl;
} else{
addClientToLine(colaPasillo, client);
}
}
void Preferencial(ListaDoblePreferencial *preferencial, ColaEspera *colaPreferencial){
Client client = CreateClient();
bool spots = preferencial->showSpotsAvailable();
if(spots){
cout << "These are the available spots" << endl;
cout << "Please select one from the above list" << endl;
int position;
cin >> position;
bool result = preferencial->insertClient(client, position);
if(result){
cout << "The reservation was successful" << endl;
}else{
cout << "The reservation failed, the spot is not available" << endl;
}
}else {
addClientToLine(colaPreferencial, client);
}
}
string askId(){
cout << "What is your id" << endl;
string id;
cin >> id;
return id;
}
void payReserve(ListaDoblePreferencial *preferencial, PilaPasillo *hall, ListaGeneral *general){
cout << "Which place would you like to pay the reserve" << endl;
cout << "1. Preferential" << endl;
cout << "2. Hall" << endl;
cout << "3. General" << endl;
cout << "4. Exit " << endl;
int answer;
cin >> answer;
switch (answer) {
case 1:{
if(preferencial->searchClient(askId())){
cout << "Your reserve is paid, enjoy the function" << endl;
} else{
cout << "Your reserve was not found" << endl;
}
break;
}
case 2:{
if(hall->searchClient(askId())){
cout << "Your reserve is paid, enjoy the function" << endl;
}else{
cout << "Your reserve was not found" << endl;
}
break;
}
case 3:{
if(general->searchClient(askId())){
cout << "Your reserve is paid, enjoy the function" << endl;
} else{
cout << "Your reserve was not found" << endl;
}
break;
}
}
}
void Reserve(ListaDoblePreferencial *preferencial, ColaEspera *colaPreferencial, PilaPasillo *hall, ColaEspera *colaPasillo, ListaGeneral *general, ColaEspera *colaGeneral){
cout << "Which place would you like to reserve" << endl;
cout << "1. Preferential 10.000 colones" << endl;
cout << "2. Hall 7.000 colones" << endl;
cout << "3. General 4.000 colones " << endl;
cout << "4. Exit " << endl;
int answer;
cin >> answer;
switch (answer) {
case 1:{
Preferencial(preferencial, colaPreferencial);
break;
}
case 2:{
Hall(hall, colaPasillo);
break;
}
case 3:{
General(general, colaGeneral);
break;
}
case 4:{
return;
}
}
}
int main() {
ColaEspera *colaPreferencial = new ColaEspera();
ColaEspera *colaPasillo = new ColaEspera();
ListaDoblePreferencial *preferencial = new ListaDoblePreferencial();
PilaPasillo *hall = new PilaPasillo();
ListaGeneral* general = new ListaGeneral();
ColaEspera *colaGeneral = new ColaEspera();
cout << "****Welcome to movies Sullivan****" << endl;
Client pClient = Client("Joss", "13");
Client pClient2 = Client("vader", "14");
Client pClient3 = Client("leia", "17");
Client pClient4 = Client("anthony", "18");
Client pClient5 = Client("isa", "19");
Client pClient6 = Client("cami", "20");
Client pClient7 = Client("vayo", "21");
Client pClient8 = Client("severus", "22");
Client pClient9 = Client("it", "23");
Client pClient0= Client("lady", "24");
preferencial->insertClient(pClient, 1);
preferencial->insertClient(pClient2, 2);
preferencial->insertClient(pClient3, 3);
preferencial->insertClient(pClient4, 4);
preferencial->insertClient(pClient5, 5);
preferencial->insertClient(pClient6, 6);
preferencial->insertClient(pClient7, 7);
preferencial->insertClient(pClient8, 8);
preferencial->insertClient(pClient9, 9);
hall->push(pClient);
hall->push(pClient2);
hall->push(pClient3);
hall->push(pClient4);
hall->push(pClient5);
hall->push(pClient6);
hall->push(pClient7);
hall->push(pClient8);
hall->push(pClient9);
hall->push(pClient0);
hall->push(pClient2);
hall->push(pClient3);
hall->push(pClient4);
hall->push(pClient5);
hall->push(pClient6);
hall->push(pClient7);
hall->push(pClient8);
hall->push(pClient9);
hall->push(pClient0);
general->addClient(pClient);
general->addClient(pClient2);
general->addClient(pClient3);
general->addClient(pClient4);
general->addClient(pClient5);
general->addClient(pClient6);
general->addClient(pClient7);
general->addClient(pClient8);
general->addClient(pClient9);
general->addClient(pClient0);
general->addClient(pClient2);
general->addClient(pClient3);
general->addClient(pClient4);
general->addClient(pClient5);
general->addClient(pClient6);
general->addClient(pClient7);
general->addClient(pClient8);
general->addClient(pClient9);
general->addClient(pClient0);
bool exit = false;
while (!exit){
cout << "1. Reserve" << endl;
cout << "2. Pay the reserve" << endl;
cout << "3. Exit" << endl;
int answer;
cin >> answer;
switch (answer) {
case 1:{
Reserve(preferencial, colaPreferencial, hall, colaPasillo, general, colaGeneral);
break;
}
case 2:{
payReserve(preferencial,hall,general);
break;
}
case 3:
exit = true;
break;
default:
continue;
}
}
}