-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCircular.cpp
129 lines (120 loc) · 2.61 KB
/
Circular.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
#include <iostream>
using namespace std;
#define SIZE 5
class Pizza
{
int porder[SIZE];
int front, rear;
public:
Pizza()
{
front = rear = -1;
}
int qfull()
{
if ((front == 0 && rear == SIZE - 1) || (front == rear + 1))
return 1;
return 0;
}
int qempty()
{
if (front == -1)
return 1;
return 0;
}
void accept_order(int);
void make_payment(int);
void order_in_queue();
};
void Pizza::accept_order(int item)
{
if (qfull())
cout << "\nVery Sorry !!!! No more orders....\n";
else
{
if (front == -1)
{
front = rear = 0;
}
else
{
rear = (rear + 1) % SIZE;
}
porder[rear] = item;
}
}
void Pizza::make_payment(int n)
{
int item;
if (qempty())
cout << "\nSorry !!! No order is there...\n";
else
{
cout << "\nDelivered orders as follows...\n";
for (int i = 0; i < n; i++)
{
item = porder[front];
if (front == rear)
{
front = rear = -1;
}
else
{
front = (front + 1) % SIZE;
}
cout << "\t" << item;
}
cout << "\nTotal amount to pay: " << n * 100;
cout << "\nThank you! Visit again....\n";
}
}
void Pizza::order_in_queue()
{
int temp;
if (qempty())
{
cout << "\nSorry !! There is no pending order...\n";
}
else
{
temp = front;
cout << "\nPending orders as follows..\n";
while (temp != rear)
{
cout << "\t" << porder[temp];
temp = (temp + 1) % SIZE;
}
cout << "\t" << porder[temp];
}
}
int main()
{
Pizza p1;
int ch, k, n;
do
{
cout << "\n\t***** Welcome To Pizza Parlor *******\n";
cout << "\n1. Accept order\n2. Make payment\n3. Pending Orders\nEnter your choice: ";
cin >> ch;
switch (ch)
{
case 1:
cout << "\nWhich Pizza do you like most....\n";
cout << "\n1. Veg Soya Pizza\n2. Veg Butter Pizza\n3. Egg Pizza";
cout << "\nPlease enter your order: ";
cin >> k;
p1.accept_order(k);
break;
case 2:
cout << "\nHow many pizzas? ";
cin >> n;
p1.make_payment(n);
break;
case 3:
cout << "\nFollowing orders are in queue to deliver....\n";
p1.order_in_queue();
break;
}
} while (ch != 4);
return 0;
}