-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
169 lines (141 loc) · 8.95 KB
/
main.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
#include <iostream>
#include <string>
#include "Classes/Menu.h"
#include "Classes/Company.h"
#include <time.h>
using namespace std;
void faznada() {};
int main() {
Company ugh("../Data/");
Client* openClient;
Worker* openWorker;
Base* openBase;
// Start program message
line(35);
cout << setw(35) << setfill (' ') << "Ugh-Eats v1.0" << endl;
cout << setw(35) << setfill (' ') << "~The future of food~" << endl;
// Menu creation
Menu startMenu("Welcome!");
Menu clientMenu("Ugh-Eats");
Menu restaurantsMenu("Search Restaurants");
Menu clientAccountManagementMenu("Account management");
Menu adminMenu("Ugh-Eats - Admin");
Menu adminClientManagementMenu("Client management");
Menu adminWorkerManagementMenu("Worker management");
Menu adminWorkerViewMenu("View workers");
Menu adminVehicleManagementMenu("Vehicle management");
Menu adminVehicleViewMenu("View Vehicles");
Menu adminRestaurantManagementMenu("Restaurant management");
Menu adminRestaurantViewMenu("View restaurants");
Menu adminRestaurantProductsMenu("Products");
Menu adminRestaurantOrdersMenu("View orders");
Menu adminFinanceMenu("Finance");
// startMenu creation
startMenu.addOption("Exit", faznada);
startMenu.addOption("Log-in", [&](){openClient = clientLogin(ugh); if (openClient!= nullptr) {openBase = openClient->getBase(); clientMenu.start();}});
startMenu.addOption("Sign-up", [&](){createClientAccount(ugh);});
startMenu.addOption("Admin", [&](){openWorker = adminLogin(ugh); if (openWorker!= nullptr) {openBase = openWorker->getWorkerBase(); adminMenu.start();}});
// clientMenu creation
clientMenu.addOption("Log-out", faznada);
clientMenu.addOption("Make an order", [&](){restaurantsMenu.start();});
clientMenu.addOption("Order history", [&](){viewClientOrdersHistory(*openClient);});
clientMenu.addOption("Account management", [&](){clientAccountManagementMenu.start();});
// restaurantsMenu
restaurantsMenu.addOption("Go back", faznada);
restaurantsMenu.addOption("All restaurants", [&](){makeOrderDeliveryAll(*openClient, openBase);});
restaurantsMenu.addOption("By name", [&](){makeOrderDeliveryByRestaurant(*openClient,openBase);});
restaurantsMenu.addOption("By municipality", [&](){makeOrderDeliveryByMunicipality(*openClient,openBase);});
restaurantsMenu.addOption("By price range", [&](){makeOrderDeliveryByPrice(*openClient,openBase);});
restaurantsMenu.addOption("By cuisine", [&](){makeOrderDeliveryByCuisine(*openClient,openBase);});
// clientAccountManagementMenu creation
clientAccountManagementMenu.addOption("Go back", faznada);
clientAccountManagementMenu.addOption("View info", [&](){cout << *openClient; enterWait();});
clientAccountManagementMenu.addOption("Edit info", [&](){editClientInfo(ugh,*openClient);});
clientAccountManagementMenu.addOption("Delete account", [&](){deleteClientAccount(openClient,openBase);});
// adminMenu creation
adminMenu.addOption("Log-out", faznada);
adminMenu.addOption("Client management", [&](){adminClientManagementMenu.start();});
adminMenu.addOption("Worker management", [&](){adminWorkerManagementMenu.start();});
adminMenu.addOption("Vehicle management", [&](){adminVehicleManagementMenu.start();});
adminMenu.addOption("Restaurant management", [&](){adminRestaurantManagementMenu.start();});
adminMenu.addOption("Finance", [&](){adminFinanceMenu.start();});
// adminClientManagementMenu creation
adminClientManagementMenu.addOption("Go back", faznada);
adminClientManagementMenu.addOption("View all clients", [&](){showAllClients(ugh);});
adminClientManagementMenu.addOption("View clients by base", [&](){showClientsByBase(ugh);});
adminClientManagementMenu.addOption("View specific client", [&](){showSpecificClient(ugh);});
// adminWorkerManagementMenu creation
adminWorkerManagementMenu.addOption("Go back", faznada);
adminWorkerManagementMenu.addOption("View base workers", [&](){adminWorkerViewMenu.start();});
adminWorkerManagementMenu.addOption("Hire worker", [&](){hireWorker(openBase);});
adminWorkerManagementMenu.addOption("Edit worker info", [&](){editWorkerInfo(openBase);});
adminWorkerManagementMenu.addOption("Fire worker", [&](){fireWorker(openBase);});
// adminWorkerViewMenu creation
adminWorkerViewMenu.addOption("Go back", faznada);
adminWorkerViewMenu.addOption("View all base workers", [&](){showWorkers(openBase);});
adminWorkerViewMenu.addOption("View all active workers", [&](){showActiveWorkers(openBase);});
adminWorkerViewMenu.addOption("View all old workers", [&](){showOldWorkers(openBase);});
adminWorkerViewMenu.addOption("View base Administrators", [&](){showAdmins(openBase);});
adminWorkerViewMenu.addOption("View base Deliverypersons", [&](){showDeliverypersons(openBase);});
adminWorkerViewMenu.addOption("View base Repairman", [&](){showRepairman(openBase);});
adminWorkerViewMenu.addOption("View specific worker", [&](){showSpecificWorker(openBase);});
// adminVehicleManagementMenu creation
adminVehicleManagementMenu.addOption("Go back", faznada);
adminVehicleManagementMenu.addOption("View base vehicles", [&](){adminVehicleViewMenu.start();});
adminVehicleManagementMenu.addOption("Send vehicle to maintenance", [&](){openBase->vehicleToMaintenance();});
adminVehicleManagementMenu.addOption("Change Deliveryperson vehicle", [&](){changeDeliveryPersonVehicle(openBase);});
// adminVehicleViewMenu creation
adminVehicleViewMenu.addOption("Go back", faznada);
adminVehicleViewMenu.addOption("View all vehicles", [&](){showBaseVehicles(openBase);});
adminVehicleViewMenu.addOption("View specific vehicle", [&](){showSpecificVehicle(openBase);});
adminVehicleViewMenu.addOption("View available vehicles", [&](){showAvailableVehicles(openBase);});
adminVehicleViewMenu.addOption("View occupied vehicles", [&](){showVehiclesUnderMaintenance(openBase);});
// adminRestaurantManagementMenu creation
adminRestaurantManagementMenu.addOption("Go back", faznada);
adminRestaurantManagementMenu.addOption("View restaurants", [&](){adminRestaurantViewMenu.start();});
adminRestaurantManagementMenu.addOption("View orders", [&](){adminRestaurantOrdersMenu.start();});
adminRestaurantManagementMenu.addOption("Products", [&](){adminRestaurantProductsMenu.start();});
adminRestaurantManagementMenu.addOption("Add new restaurant", [&](){addRestaurant(openBase);});
adminRestaurantManagementMenu.addOption("Remove restaurant", [&](){removeRestaurant(openBase);});
// adminRestaurantViewMenu creation
adminRestaurantViewMenu.addOption("Go back", faznada);
adminRestaurantViewMenu.addOption("View all restaurants", [&](){showAllRestaurants(ugh);});
adminRestaurantViewMenu.addOption("View restaurants by base", [&](){showRestaurantsByBase(ugh);});
adminRestaurantViewMenu.addOption("View specific restaurant", [&](){showSpecificRestaurant(ugh);});
// adminRestaurantOrdersMenu creation
adminRestaurantOrdersMenu.addOption("Go back", faznada);
adminRestaurantOrdersMenu.addOption("View all orders", [&](){showBaseOrders(openBase);});
adminRestaurantOrdersMenu.addOption("View orders by restaurant", [&](){showSpecificRestaurantsOrders(openBase);});
adminRestaurantOrdersMenu.addOption("View orders by client", [&](){showSpecificClientOrders(openBase);});
//adminRestaurantProductsMenu creation
adminRestaurantProductsMenu.addOption("Go back", faznada);
adminRestaurantProductsMenu.addOption("Add product", [&](){addProduct(openBase);});
adminRestaurantProductsMenu.addOption("Remove product", [&](){removeProduct(openBase);});
adminRestaurantProductsMenu.addOption("View all products",[&](){showAllProducts(openBase);});
adminRestaurantProductsMenu.addOption("View products by restaurant",[&](){showProductsByRestaurant(openBase);});
adminRestaurantProductsMenu.addOption("View products by cuisine",[&](){showProductsByCuisine(openBase);});
// adminFinanceMenu creation
adminFinanceMenu.addOption("Go back", faznada);
adminFinanceMenu.addOption("Company earnings", [&](){showCompanyTotalEarnings(ugh);});
adminFinanceMenu.addOption("Base earnings", [&](){showEarningsByBase(openBase);});
// Start!
startMenu.start();
string str;
cout << "Do you want to save changes to file (Y/N): ";
getline(cin, str);
if (str == "Y" || str == "y") {
updateBasesFile(ugh);
updateCompanyFile(ugh);
for (int i = 0; i < ugh.getCompanyBases().size(); i++) {
updateClientsFile(ugh.getCompanyBases().at(i));
updateWorkersFile(ugh.getCompanyBases().at(i));
updateRestaurantsFile(ugh.getCompanyBases().at(i));
updateProductsFile(ugh.getCompanyBases().at(i));
updateOrdersFile(ugh.getCompanyBases().at(i));
}
cout << "Files saved successfully!" << endl;
} else {
cout << "Files not saved" << endl;
}
return 0;
}