-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathE32.cpp
executable file
·324 lines (220 loc) · 5.68 KB
/
E32.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
/* DSL – EXPERIMENT 13 – E32 */
#include <iostream>
using namespace std;
#define MAX 5
string arr[3] = {"Veg Soya Pizza", "Veg butter Pizza", "Chicken Pizza"};
class Pizza {
int order[MAX];
int front,rear;
public:
Pizza() {
front = rear = -1;
}
int isFull() {
return ((front == 0) && (rear == (MAX - 1)) || (front == (rear + 1) % MAX));
}
int isEmpty() {
return (front == -1);
}
void accept_order(int);
void make_payment(int);
void order_in_queue();
};
void Pizza::accept_order(int item) {
if (isFull())
cout<<"\nVery Sorry !!!! No more orders....\n";
else {
if (front == -1)
front = rear = 0;
else
rear = (rear + 1) % MAX;
order[rear] = item;
}
}
void Pizza::make_payment(int n) {
int item;
char ans;
if (isEmpty())
cout<<"\nSorry !!! There are no pending orders....\n";
else {
cout<<"\nDeliverd orders as follows...\n";
for(int i = 0; i < n; i++) {
item = order[front];
if(front == rear)
front = rear = -1;
else
front = (front + 1) % MAX;
cout << arr[item - 1] << " , ";
}
cout << "\n\nTotal amount to pay = " << n * 100;
cout << "\nThank you visit Again....\n";
}
}
void Pizza::order_in_queue() {
int i;
if (isEmpty())
cout << "\nSorry !! There is no pending order...\n";
else {
i = front;
cout << "\nPending Order as follows..\n";
while (i != rear) {
cout << arr[order[i] - 1] << " , ";
i = (i + 1) % MAX;
}
cout << arr[order[i] - 1] << "\n";
}
}
int main()
{
Pizza pizza;
int ch,k,n;
do {
cout<< "\n\n\t***** Welcome To Pizza Parlor *******\n"
<< "\n1. Accept order\n2. Make_payment\n3. Pending Orders\n4. Exit"
<< "\nEnter your choice: ";
cin >> ch;
switch(ch) {
case 1:
cout<< "\nWhich Pizza do u like most....\n"
<< "\n1. Veg Soya Pizza\n2. Veg butter Pizza\n3. Chicken Pizza"
<< "\nPlease enter your order: ";
cin >> k;
pizza.accept_order(k);
break;
case 2:
cout << "\nHow many Pizza do you want? ";
cin >> n;
pizza.make_payment(n);
break;
case 3:
cout << "\nFollowing orders are in queue to deliver....as follows..\n";
pizza.order_in_queue();
break;
}
} while (ch != 4);
return 0;
}
/*
------------------ OUTPUT -------------------
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 1
Which Pizza do u like most....
1. Veg Soya Pizza
2. Veg butter Pizza
3. Chicken Pizza
Please enter your order: 1
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 1
Which Pizza do u like most....
1. Veg Soya Pizza
2. Veg butter Pizza
3. Chicken Pizza
Please enter your order: 2
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 1
Which Pizza do u like most....
1. Veg Soya Pizza
2. Veg butter Pizza
3. Chicken Pizza
Please enter your order: 3
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 1
Which Pizza do u like most....
1. Veg Soya Pizza
2. Veg butter Pizza
3. Chicken Pizza
Please enter your order: 1
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 1
Which Pizza do u like most....
1. Veg Soya Pizza
2. Veg butter Pizza
3. Chicken Pizza
Please enter your order: 2
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 1
Which Pizza do u like most....
1. Veg Soya Pizza
2. Veg butter Pizza
3. Chicken Pizza
Please enter your order: 3
Very Sorry !!!! No more orders....
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 3
Following orders are in queue to deliver....as follows..
Pending Order as follows..
Veg Soya Pizza , Veg butter Pizza , Chicken Pizza , Veg Soya Pizza , Veg butter Pizza
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 2
How many Pizza do you want? 3
Deliverd orders as follows...
Veg Soya Pizza , Veg butter Pizza , Chicken Pizza
Total amount to pay = 300
Thank you visit Again....
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 3
Following orders are in queue to deliver....as follows..
Pending Order as follows..
Veg Soya Pizza , Veg butter Pizza
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 2
How many Pizza do you want? 2
Deliverd orders as follows...
Veg Soya Pizza , Veg butter Pizza
Total amount to pay = 200
Thank you visit Again....
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 3
Following orders are in queue to deliver....as follows..
Sorry !! There is no pending order...
***** Welcome To Pizza Parlor *******
1. Accept order
2. Make_payment
3. Pending Orders
4. Exit
Enter your choice: 4
*/