-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
280 lines (238 loc) · 9.02 KB
/
Copy pathmain.cpp
File metadata and controls
280 lines (238 loc) · 9.02 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#include "header.h"
#include "graph.h"
#include "avl.h"
#include <windows.h>
#include <iomanip>
#include <fstream>
using namespace std;
// Function to set console text color
void setConsoleColor(int color) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, color);
}
// Function to print a centered, colored title box
void printBoxedTitle(const string& title, int color = 11) {
setConsoleColor(color);
cout << "\n\t+-------------------------------------------------------------+\n";
int padding = (61 - title.length()) / 2;
cout << "\t|";
for (int i = 0; i < padding; i++) cout << ' ';
cout << title;
for (int i = 0; i < 60 - (padding + title.length()); i++) cout << ' ';
cout << "|\n";
cout << "\t+-------------------------------------------------------------+\n";
setConsoleColor(7);
}
// Function to print colored and framed location info
void printLocationBox(const string& location) {
setConsoleColor(3);
cout << "\n\t==============================================================\n";
cout << "\t|| LOCATED AT: " << setw(30) << left << location << " ||\n";
cout << "\t==============================================================\n\n";
setConsoleColor(7);
}
// Function to print centered bold menu heading with box
void printCenteredBoldMenuTitle(const string& title) {
setConsoleColor(12); // Light red
int width = 61;
int padding = (width - title.length()) / 2;
cout << "\n\t+-------------------------------------------------------------+\n";
cout << "\t|" << string(padding, ' ') << title << string(60 - padding - title.length(), ' ') << "|\n";
cout << "\t+-------------------------------------------------------------+\n";
setConsoleColor(10); // Green for menu content
}
// Function to print formatted menu entries
void printFormattedMenu(string menu[], int price[], int size) {
setConsoleColor(10);
cout << "\t+-------------------------------------------------------------+\n";
for (int i = 1; i <= size; i++) {
cout << "\t| " << setw(2) << i << ". " << setw(22) << left << menu[i] << " - Rs. " << setw(5) << right << price[i] << " |" << endl;
}
cout << "\t+-------------------------------------------------------------+\n";
setConsoleColor(7);
}
string deliveryPoints[] = { "PizzaSHOP", "Chauburji", "Shadman", "Islampura", "JoharTown", "Anarkali" };
int main() {
ofstream o1("order.txt", ios::trunc);
ofstream o2("served.txt", ios::trunc);
o1.close();
o2.close();
PizzaShop* myPizzaShop = new PizzaShop;
myPizzaShop->shopName = "HRM Pizza Hut!";
myPizzaShop->address = "COMSATS University, Wah";
myPizzaShop->menu = new string[11]{ "", "chickenTikka", "arabicRanch", "chickenFajita", "cheeseLover", "chickenSupreme", "allveggie", "garlicWest", "BeefBold", "phantom", "mexicanDelight" };
myPizzaShop->price = new int[11]{ 0, 2000, 2500, 2400, 2200, 2700, 2000, 2100, 3000, 3000, 2800 };
int option;
while (true) {
// system("cls");
printBoxedTitle(myPizzaShop->shopName, 14); // Yellow title
printLocationBox(myPizzaShop->address); // Teal location box
printCenteredBoldMenuTitle("Our Menu:");
printFormattedMenu(myPizzaShop->menu, myPizzaShop->price, 10);
setConsoleColor(11); // Light Cyan
cout << "\n\t====================== Operations Menu ======================\n";
setConsoleColor(11); cout << "\t1. "; setConsoleColor(10); cout << "Place order\n";
setConsoleColor(11); cout << "\t2. "; setConsoleColor(12); cout << "Serve order\n";
setConsoleColor(11); cout << "\t3. "; setConsoleColor(14); cout << "Display all pending orders\n";
setConsoleColor(11); cout << "\t4. "; setConsoleColor(13); cout << "Display all served Orders\n";
setConsoleColor(11); cout << "\t5. "; setConsoleColor(9); cout << "Search Served Orders\n";
setConsoleColor(11); cout << "\t6. "; setConsoleColor(12); cout << "Clear the Served Orders List\n";
setConsoleColor(11); cout << "\t7. "; setConsoleColor(6); cout << "Display total bill of Pending Orders\n";
setConsoleColor(11); cout << "\t8. "; setConsoleColor(10); cout << "Display the total Earnings of Served Orders\n";
setConsoleColor(11); cout << "\t9. "; setConsoleColor(3); cout << "View All Placed Orders from File\n";
setConsoleColor(11); cout << "\t10. "; setConsoleColor(3); cout << "View All Served Orders from File\n";
setConsoleColor(11); cout << "\t11. "; setConsoleColor(4); cout << "Clear Placed Orders File (order.txt)\n";
setConsoleColor(11); cout << "\t12. "; setConsoleColor(4); cout << "Clear Served Orders File (served.txt)\n";
setConsoleColor(11); cout << "\t13. "; setConsoleColor(14); cout << "EXIT\n";
setConsoleColor(6); // Yellow input prompt
cout << "\n\tEnter your choice: ";
setConsoleColor(9);
cin >> option;
// === Original logic here ===
switch (option) {
case 1: {
int type;
cout<<"-------Select Customer Type-------"<<endl;
cout<<"1.Take away customer"<<endl;
cout<<"2.Dine In customer"<<endl;
cout<<"3.Home Delivery customer"<<endl;
cin>>type;
customer c=insertData(myPizzaShop);
if(type==1){
placeTakeAwayOrder(c);
}
else if(type==2){
placeDineInOrder(c);
}
else if(type==3){
setDeliveryGraph();
int dist[6];
dijkstra(0, dist);
int deliveryChoice = 0;
cout << "\nAvailable delivery areas:\n";
for (int i = 1; i <= 5; i++) {
cout << i << ". " << deliveryPoints[i] << "\n";
}
while (deliveryChoice < 1 || deliveryChoice > 5) {
cout << "Enter the number of your area (1 to 5): ";
cin >> deliveryChoice;
}
string address = deliveryPoints[deliveryChoice];
// calculate delivery charges and total bill
int deliveryChargesPerKM = 50;
int distanceFromShop = dist[deliveryChoice];
int deliveryCharges = distanceFromShop * deliveryChargesPerKM;
c.bill += deliveryCharges;
placeHomeOrders(c, address, deliveryCharges, distanceFromShop);
}
else{
cout<<"Invalid choice!"<<endl;
}
} break;
case 2: {
int type;
cout<<"-------Select Customer To Serve-------"<<endl;
cout<<"1.Serve order for take away customer"<<endl;
cout<<"2.Serve order for dine in customer"<<endl;
cout<<"3.Serve order for home delivery customer"<<endl;
cout<<"4.Serve all orders."<<endl;
cin>>type;
if(type==1){
serveTakeAway();
}
else if(type==2){
serveDineInOrder();
}
else if(type==3){
serveHomeOrder();
}
else if(type==4){
serveAllOrders();
}
else{
cout<<"Invalid choice!"<<endl;
}
} break;
case 3: {
int type;
cout<<"-------Select Order To Display-------"<<endl;
cout << "1. Display all orders of Take-Away Customer\n";
cout << "2. Display all orders of Home Delivery Customers\n";
cout << "3. Display all orders of Dine-In Customers\n";
cout << "4. Display all orders of all Customers\n";
cin>>type;
if(type==1){
displayTakeAwayOrders();
}
else if(type==2){
displayHomeOrders();
}
else if(type==3){
displayDineInOrders();
}
else if(type==4){
displayAllOrders();
}
else{
cout<<"Invalid choice!"<<endl;
}
} break;
case 4: {
if (root == NULL)
cout << "No Served Customer yet." << endl;
else
displayAllServedOrders(root);
} break;
case 5: {
string name;
cout << "Enter the name of the customer you want to search: ";
cin >> name;
nodeA* searchedCustomer = searchCustomer(root, name);
if (searchedCustomer == NULL)
cout << "No such Customer was Served." << endl;
else
display(searchedCustomer);
} break;
case 6: {
if (root == NULL) {
cout << "No served orders to clear." << endl;
}
else {
deleteAllServedCustomers(root);
root=NULL;
cout << "All served orders cleared!" << endl;
}
} break;
case 7: {
totalbillofPendingOrders();
} break;
case 8: {
double totalx = totalEarnings(root);
cout << "The Total Earnings are: Rs. " << totalx << endl;
} break;
case 9: {
cout << "\n--- All Placed Orders (order.txt) ---\n";
readFromFile("order.txt");
break;
}
case 10: {
cout << "\n--- All Served Orders (served.txt) ---\n";
readFromFile("served.txt");
break;
}
case 11:
clearFile("order.txt");
break;
case 12:
clearFile("served.txt");
break;
case 13:
cout << "\nPizza Order Management System -- Terminated" << endl;
cout << "Thank you for using our services!" << endl;
return 0;
default:
cout << "Invalid option. Please try again." << endl;
}
}
return 0;
}