-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.hpp
More file actions
1042 lines (986 loc) · 40.3 KB
/
MainMenu.hpp
File metadata and controls
1042 lines (986 loc) · 40.3 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
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// MainMenu.hpp
// comp252_final
//
// Created by Matthew Haddad on 11/9/19.
// Copyright © 2019 Matthew Haddad. All rights reserved.
//
#ifndef MainMenu_hpp
#define MainMenu_hpp
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include "ClassTypes.hpp"
#include "Management_System.hpp"
#include "Kitchen_System.hpp"
#include "Order_System.hpp"
class MainMenu{
public:
void mMenu();
void readFileData();
void writeFileData();
void clearFile(std::string file);
void loadIngredientData();
void loadMenuOptionData();
void loadMenuData();
void viewCompletedOrders();
void open_management_system_options();
void open_order_system_options();
void open_kitchen_system_options();
void open_inventory_options();
void open_menu_options();
void open_order_options();
void open_discount_options();
void open_ingredient_options();
void open_meal_options();
void open_waiter_options();
private:
std::vector<Ingredient> Ingredients;
std::vector<MenuOption> MenuOptions;
std::vector<Discount> Discounts;
std::vector<Menu> Menus;
std::vector<Order> Orders;
std::vector<Waiter> Waiters;
std::vector<Table> Tables;
int option_select;
int tableCounter = 1;
};
void MainMenu::mMenu(){
readFileData();
std::cout << "Welcome to Data's Diner!\n";
std::cout << "Enter the number of the option you want or -1 to exit:\n";
std::cout << "1. Management System\n2. Order System\n3. Kitchen System\n>> ";
std::cin >> option_select;
switch(option_select){
case(1): open_management_system_options(); break;
case(2): open_order_system_options(); break;
case(3): open_kitchen_system_options(); break;
case(-1):
writeFileData();
std::cout << "Thank you for using the Diner Management System. Have a good day.\n";
exit(0);
}
}
void MainMenu::open_management_system_options(){
std::cout << "Welcome to the diner management system!\nEnter a number to view options:\n";
std::cout << "1. Inventory & Menu Options\n2. View Completed Orders\n3. Add New Waiters\n";
std::cout << "4. Manage Coupons and Discounts\n5. Manage Seating Layout\n6. Go Back\n>> ";
std::cin >> option_select;
switch(option_select){
case(1): open_inventory_options(); break;
case(2): open_order_options(); break;
case(3): open_waiter_options(); break;
case(4): open_discount_options(); break;
case(5): open_seating_options(); break;
case(6): mMenu(); break;
}
}
void MainMenu::open_kitchen_system_options() {
std::cout << "Welcome to the diner kitchen system!\nSelect an option:\n";
std::cout << "\t[1]Display Active Orders\n\t[2]Display the Progress of Each Active Order\n\t[3]Display Meal Preferences and Options\n\t[4]Go Back\n>>";
std::cin >> option;
while (option < 1 || option > 4 || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option:\n>>";
std::cin >> option;
};
switch (option) {
case(1): {
std::cout << "\n[ACTIVE ORDERS]\n";
std::cout << " -------------------------------------------------------" << std::endl;
std::cout << "| Table #\tActive Order(s)" << std::setw(26) << "|" << std::endl;
std::cout << " -------------------------------------------------------" << std::endl;
//displays active orders from Orders
int oCount = 1;
for (Order o : Orders) {
displayActiveOrders(o, oCount);
oCount++;
}
//displays active orders from Tables
int tCount = 1;
for (Table t : Tables) {
for (Order o : t.orders) {
displayActiveTableOrders(t, tCount);
}
tCount++;
}
std::cout << " -------------------------------------------------------end\n" << std::endl;
break;
}
case(2): {
std::cout << "\n[ORDERS PROGRESS]\n";
std::cout << " -------------------------------------------------------------------------------" << std::endl;
std::cout << "| Table #" << std::setw(22) << "Elapsed Time" << std::setw(12) << "Progress" << std::setw(13) << "Order" << std::setw(25) << "|" << std::endl;
std::cout << " -------------------------------------------------------------------------------" << std::endl;
int tCount = 1;
for (Table t : Tables) {
displayTableProgress(t, tCount);
tCount++;
}
int oCount = 1;
for (Order o : Orders) {
displayOrderProgress(o, oCount);
oCount++;
}
std::cout << " -------------------------------------------------------------------------------\n" << std::endl;
break;
}
case(3): {
std::cout << "\n[MEAL PREFERENCES]\n";
std::cout << " ---------------------------------------------------------------------------------------------------------------" << std::endl;
std::cout << "| Order Name\tCook Options" << std::setw(67) << "Ingredients(Optional to remove)" << std::setw(18) << "|" << std::endl;
std::cout << " ---------------------------------------------------------------------------------------------------------------" << std::endl;
for (MenuOption m: MenuOptions) {
displayMealPreferences(m);
}
std::cout << " ---------------------------------------------------------------------------------------------------------------\n" << std::endl;
break;
}
case(4): {
mMenu();
}
default: {
std::cout << "Input does not match any of the options." << std::endl;
open_kitchen_system_options();
}
}
open_kitchen_system_options();
}
void MainMenu::open_order_system_options() // main function for all order system tasks
{
orderSystem:
std::cout << "Welcome to the Diner Order System \nPlease select an option:\n";
std::cout << "\t[1]Place an Order\n\t[2]View Options\n\t[3]Print Final Receipt\n\t[4]Delete Options\n\t[5]Go Back\n>> ";
std::cin >> userChoice;
while (userChoice < 1 || userChoice > 5 || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option \n>>";
std::cin >> userChoice;
};
switch (userChoice)
{
case 1: // case 1 used to place an order
std::cout << "What kind of order do you want to place?\n";
std::cout << "\t[1]Order To Go\n\t[2]Order For Here\n\t[3]Add to Existing Order\n\t[4]Go Back\n>> ";
std::cin >> userChoice;
while (userChoice < 1 || userChoice > 4 || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option \n>> ";
std::cin >> userChoice;
};
if (userChoice == 1) //used for placing an order to go
{
Order newOrder;
int counter = 1;
viewActiveMenu();
for (MenuOption m : MenuOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << "\n";
counter++;
}
std::cout << std::endl;
std::cout << "What would you like to order? \n";
std::cout << ">>";
std::cin >> option_select;
//initializes orderBeginTime with current time and sets orderInProgress to true
newOrder.orderBeginTime = time(NULL);
for (MenuOption m : MenuOptions)
{
int cookTime = m.CookTime;
newOrder.orderEndTime = newOrder.orderBeginTime + cookTime;
}
newOrder.orderInProgress = true;
std::cout << "Your order is now In Progress" << std::endl;
newOrder.OrderOptions.push_back(MenuOptions[option_select - 1]);
Orders.push_back(newOrder);
goto orderSystem;
}
else if (userChoice == 2) // used to place an order for here
{
Table newTable;
Order newOrder;
int counter = 1;
viewActiveMenu();
for (MenuOption m : MenuOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << "\n";
counter++;
}
std::cout << std::endl;
std::cout << "What would you like to order? \n";
std::cout << ">>";
std::cin >> option_select;
newOrder.OrderOptions.push_back(MenuOptions[option_select - 1]);
newTable.number = tableCounter;
tableCounter++;
//initializes orderBeginTime with current time and sets orderInProgress to true
newOrder.orderBeginTime = time(NULL);
for (MenuOption m : MenuOptions)
{
int cookTime = m.CookTime;
newOrder.orderEndTime = newOrder.orderBeginTime + cookTime;
}
newOrder.orderInProgress = true;
std::cout << "Your order is now In Progress" << std::endl;
newTable.orders.push_back(newOrder);
Tables.push_back(newTable);
goto orderSystem;
}
else if (userChoice == 3) // used to add to an existing order for table
{
Table newTable;
Order newOrder;
viewActiveSubOrder();
int tableChoice;
int counter = 1;
for (Table t : Tables)
{
for (Order o : t.orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << "." << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << t.number << "\n";
}
}
}
std::cout << std::endl;
std::cout << "Which table do you want to add an order to? \n";
std::cin >> tableChoice;
newTable.number = tableChoice;
std::cout << std::endl;
viewActiveMenu();
for (MenuOption m : MenuOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << "\n";
counter++;
}
std::cout << std::endl;
std::cout << "What would you like to add to the table " << tableChoice << "\n";
std::cin >> option_select;
newOrder.OrderOptions.push_back(MenuOptions[option_select - 1]);
newTable.number = tableChoice;
newTable.orders.push_back(newOrder);
Tables.push_back(newTable);
goto orderSystem;
}
else if (userChoice == 4) // used to go back to orderSystem main menu
{
goto orderSystem;
}
break;
case 2: // case 2 is used to view different types of info
std::cout << "What information do you want to view?\n";
std::cout << "\t[1]Menu\n\t[2]Optional Ingredients\n\t[3]Cooking Preferences\n\t[4]Active Suborder\n\t[5]Transaction List\n\t[6]All Active Suborders Status\n\t[7]Go Back\n>> ";
std::cin >> userChoice;
while (userChoice < 1 || userChoice > 7 || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option \n>> ";
std::cin >> userChoice;
};
if (userChoice == 1) // using an iteration of menuoptions to print out a menu. (menuoptions are stored in a text file)
{
viewActiveMenu();
int counter = 1;
for (MenuOption m : MenuOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << "\n";
counter++;
}
}
else if (userChoice == 2)
{
std::cout << "Optional Ingredients";
}
else if (userChoice == 3)
{
std::cout << "Cooking Preferences";
}
else if (userChoice == 4) // iterates through table for orders assigned to a table and iterates through orders for orders to go.
{
viewActiveSubOrder();
int counter = 1;
for (Table t : Tables)
{
for (Order o : t.orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << t.number << "\n";
}
counter++;
}
}
for (Order o : Orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << "\n";
}
counter++;
}
std::cout << std::endl;
goto orderSystem;
}
else if (userChoice == 5) // used to show a transaction list
{
std::cout << "\n";
viewTransactionList();
int counter = 1;
double totalTableUN = 0;
double totalTableP = 0;
double totalOrderUN = 0;
double totalOrderP = 0;
double totalProfitTable = 0;
double totalProfitOrder = 0;
double totalProfit = 0;
for (Table t : Tables)
{
for (Order o : t.orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << "\n";
totalTableUN += m.UnitCost;
totalTableP += m.Price;
totalProfitTable = totalTableP - totalTableUN;
}
counter++;
}
}
for (Order o : Orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << "\n";
totalOrderUN += m.UnitCost;
totalOrderP += m.Price;
totalProfitOrder = totalOrderP - totalOrderUN;
}
counter++;
}
totalProfit = totalProfitOrder + totalProfitTable;
std::cout << "\n";
std::cout << "TOTAL PROFIT: " << std::setprecision(2) << std::fixed << totalProfit << "\n";
std::cout << "\n";
goto orderSystem;
}
else if (userChoice == 6)
{
viewActiveSubOrder();
int counter = 1;
for (Table t : Tables)
{
for (Order o : t.orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << t.number << "\n";
}
counter++;
}
}
for (Order o : Orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << "\n";
}
counter++;
}
std::cout << std::endl;
goto orderSystem;
}
else if (userChoice == 7) //used to go back to the order system main menu
{
goto orderSystem;
}
break;
case 3: // used to print a receipts
std::cout << "Which type of order do you want to print a receipt from? \n";
std::cout << "\t[1] To Go Orders \n";
std::cout << "\t[2] Table Orders \n";
std::cin >> option_select;
while (option_select < 1 || option_select > 2 || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option \n>> ";
std::cin >> option_select;
};
if (option_select == 1) //used to print a to go order receipt
{
Order newOrder;
int counter = 1;
viewActiveSubOrder();
for (Order o : Orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << "\n";
counter++;
}
break;
//counter++;
}
std::cout << std::endl;
std::cout << "Which order do you want to print a receipt from? \n";
std::cin >> option_select;
double finalPrice = 0;
double taxAmount;
double tax = .0925;
printFinalReceipts();
for (Order o : Orders)
{
while (counter != option_select - 1)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << m.name << std::setw(25) << "$" << m.Price << "\n";
finalPrice += m.Price;
taxAmount = tax * finalPrice;
finalPrice += taxAmount;
}
std::cout << "\n";
std::cout << "TAX RATE: % " << std::setprecision(4) << tax << "\n";
std::cout << "TAX AMOUNT: $" << std::setprecision(2) << std::fixed << taxAmount << "\n";
std::cout << "FINAL PRICE: $" << std::setprecision(2) << std::fixed << finalPrice << "\n";
std::cout << "\n";
break;
}
}
goto orderSystem;
}
else if (option_select == 2)
{
int counter = 1;
viewActiveSubOrder();
for (Table t : Tables)
{
for (Order o : t.orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << t.number << "\n";
}
counter++;
}
}
std::cout << std::endl;
std::cout << "Which order do you want to print a receipt for? \n";
std::cin >> option_select;
double finalPrice = 0;
double taxAmount;
double tax = .0925;
printFinalReceipts();
for (Table t : Tables)
{
while (t.number != option_select - 1)
{
for (Order o : t.orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << m.name << std::setw(25) << "$" << m.Price << "\n";
finalPrice += m.Price;
taxAmount = tax * finalPrice;
finalPrice += taxAmount;
}
std::cout << "\n";
std::cout << "TAX RATE: % " << std::setprecision(4) << tax << "\n";
std::cout << "TAX AMOUNT: $" << std::setprecision(2) << std::fixed << taxAmount << "\n";
std::cout << "FINAL PRICE: $" << std::setprecision(2) << std::fixed << finalPrice << "\n";
std::cout << "\n";
}
break;
}
}
goto orderSystem;
}
case 4: // used to delete certain info
std::cout << "What would you like to delete?\n";
std::cout << "\t[1]Delete Active SubOrder\n\t[2]Delete Transaction List\n\t[3]Go Back\n";
std::cin >> userChoice;
while (userChoice < 1 || userChoice > 3 || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option \n>> ";
std::cin >> userChoice;
};
if (userChoice == 1) //used to delete an active suborder.
{
int counter = 1;
std::cout << std::endl;
std::cout << "What kind of order do you want to delete? \n";
std::cout << "\t[1] To Go Orders \n";
std::cout << "\t[2] Table Orders \n";
std::cin >> option_select;
while (userChoice < 1 || userChoice > 2 || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option \n>> ";
std::cin >> userChoice;
};
if (option_select == 1)
{
viewActiveSubOrder();
for (Order o : Orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << "\n";
}
counter++;
}
std::cout << std::endl;
std::cout << "Which order do you want to delete? \n";
std::cin >> option_select;
Orders.erase(Orders.begin() + option_select - 1);
}
else if (option_select == 2)
{
viewActiveSubOrder();
for (Table t : Tables)
{
for (Order o : t.orders)
{
for (MenuOption m : o.OrderOptions)
{
std::cout << counter << ". " << m.name << std::setw(24) << "$" << m.UnitCost << std::setw(24) << "$" << m.Price << std::setw(25) << m.CookTime << std::setw(25) << t.number << "\n";
}
counter++;
}
}
std::cout << std::endl;
std::cout << "Which order do you want to delete? \n";
std::cin >> option_select;
Tables.erase(Tables.begin() + option_select - 1);
}
goto orderSystem;
}
else if (userChoice == 2) //used to delete the transaction list of all orders
{
std::cout << "Are you sure you want to delete the transaction list? \n";
std::cout << "\t[1] Delete List\n";
std::cout << "\t[2] Go Back\n";
std::cin >> userChoice;
while (userChoice < 1 || userChoice > 2 || std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Please enter a valid option \n>> ";
std::cin >> userChoice;
};
if (userChoice == 1)
{
Tables.erase(Tables.begin());
Orders.erase(Orders.begin());
std::cout << "\n";
std::cout << "Transaction List Deleted! \n";
goto orderSystem;
}
else if (userChoice == 2)
{
std::cout << "\n";
std::cout << "Transaction List Not Deleted! \n";
goto orderSystem;
}
}
else if (userChoice == 3)
{
goto orderSystem;
}
case 5: // case 5 used to go back to the top menu
{
mMenu();
}
default:
break;
}
}
void MainMenu::open_inventory_options(){
std::cout << "Select a Menu Option:\n";
std::cout << "1. Manage Ingredients\n2. Manage Menu Options\n";
std::cout << "3. Manage Menus\n 4. Go Back\n>> ";
std::cin >> option_select;
switch(option_select){
case(1): open_ingredient_options(); break;
case(2): open_meal_options(); break;
case(3): open_menu_options(); break;
case(4): open_management_system_options(); break;
default:{
std::cout << "Invalid input.\n";
open_inventory_options();
}
}
}
void MainMenu::open_ingredient_options(){ // Menu to add, edit, view, and delete ingredients
option_select = NULL;
std::cout << "1. Add Ingredient\n2. Edit Ingredient\n";
std::cout << "3. View Ingredients\n 4. Delete Ingredient\n5. Go Back\n>> ";
std::cin >> option_select;
switch(option_select){
case(1):{
Ingredient ing = addIngredient();
Ingredients.push_back(ing);
open_ingredient_options();
break;}
case(2):{
std::cout << "Ingredients:\n";
int counter = 1;
for ( Ingredient i : Ingredients){
std::cout << counter << ". " << i.name << endl;
counter++;
}
std::cout << "Enter the number of the Ingredient you would like to edit\n>> ";
std::cin >> option_select;
Ingredients[option_select - 1] = editIngredient(Ingredients[option_select - 1]);
open_ingredient_options();
break;}
case(3):{
std::cout << "\n\t\tIngredients\n Name Quantity Cost\n";
for (Ingredient i : Ingredients){
std::cout << i.name << " " << i.quantity << " " << i.cost << endl;
}
std::cout << endl << endl;
open_ingredient_options();
break;}
case(4):{
std::cout << "Ingredients:\n";
int counter = 1;
for ( Ingredient i : Ingredients){
std::cout << counter << ". " << i.name << endl;
counter++;
}
std::cout << "Enter the number of the Ingredient you would like to remove\n>> ";
std::cin >> option_select;
Ingredients.erase(Ingredients.begin() + option_select - 1);
open_ingredient_options();
break;}
case(5):{
open_inventory_options();
writeFileData();
break;}
default:{
std::cout << "Invalid input.\n";
open_ingredient_options();
break;
}
}
}
void MainMenu::open_meal_options(){ // Menu to add, edit, view, and delete new meals/menu options
std::cout << "1. Add Order Option\n2. Edit Order Option\n";
std::cout << "3. View Order Options\n4. Delete Order Option\n5. Go Back\n>> ";
std::cin.clear();
std::cin >> option_select;
switch(option_select){
case(1):{
MenuOption newMenuOption = addMenuOption();
int counter = 1;
while (option_select != 0){
std::cout << endl;
for (Ingredient i : Ingredients){
std::cout << counter << ". " << i.name << endl;
counter++;
}
std::cin.clear();
std::cout << "What are the ingredients in this menu option?";
std::cout << " Enter a number from the list above or enter 0 to finish adding ingredients:\n>> ";
std::cin >> option_select;
if (option_select != 0){
newMenuOption.Ingredients.push_back(Ingredients[option_select - 1].name);
}
}
MenuOptions.push_back(newMenuOption);
open_meal_options();
break;
}
case(2):{
std::cout << "Menu Options:\n";
int counter = 1;
for ( MenuOption i : MenuOptions){
std::cout << counter << ". " << i.name << endl;
counter++;
}
std::cout << "Enter the number of the Menu Option you would like to edit\n>> ";
std::cin >> option_select;
MenuOptions[option_select - 1] = editMenuOption(MenuOptions[option_select - 1]);
open_ingredient_options();
break;}
case(3):{
while(option_select != 0){
std::cout << "\n\t\tOrder Options\n Name \n";
int counter = 1;
for (MenuOption i : MenuOptions){
std::cout << counter << ". " << i.name << std::endl;
counter++;
}
std::cout << "\n\nEnter the number of an order option from list above to view details or enter 0 to go back:\n>> ";
std::cin.clear();
std::cin >> option_select;
if (option_select != 0){viewMenuOption(MenuOptions[option_select -1]);}
}
open_meal_options();
}
case(4):{
std::cout << "Menu Options:\n";
int counter = 1;
for ( MenuOption i : MenuOptions){
std::cout << counter << ". " << i.name << endl;
counter++;
}
std::cout << "Enter the number of the Menu Option you would like to remove\n>> ";
std::cin >> option_select;
std::cout << "\n\n" << MenuOptions[option_select - 1].name << " successfully deleted.\n\n";
MenuOptions.erase(MenuOptions.begin() + option_select - 1);
open_meal_options();
break;}
case(5):{
writeFileData();
std::cin.clear();
open_inventory_options();
}
default:{
std::cout << "Invalid input.\n";
open_meal_options();
break;
}
}
}
void MainMenu::open_menu_options(){ // Menu to add, edit, view, and delete Menus
std::cout << "1. Add Menu\n2. Edit Menu\n";
std::cout << "3. View Menus\n 4. Delete Menu\n5. Go Back\n>> ";
std::cin >> option_select;
switch(option_select){
case(1):{
Menu newMenu = addMenu();
while (option_select != 0){
std::cout << "\n\t\tOrder Options\n Name \n";
int counter = 1;
for (MenuOption i : MenuOptions){
std::cout << counter << ". " << i.name << std::endl;
counter++;
}
std::cin.clear();
std::cout << "Enter the number of an order option to add to the menu or enter 0 to go back:\n>> ";
std::cin >> option_select;
if (option_select != 0){
newMenu.MenuOptions.push_back(MenuOptions[option_select - 1]);
std::cout << "\n\n" << MenuOptions[option_select - 1].name << " added to menu.\n\n";
}
}
Menus.push_back(newMenu);
open_menu_options();
break;
}
case(2):{
}
case(3):{
std::cout << "\n\t\tMenus\n";
int counter = 1;
for (Menu i : Menus){
std::cout << counter << ". " << i.name << std::endl;
counter++;
}
std::cin.clear();
std::cout << "Enter the number of a menu to view details or enter 0 to go back:\n>> ";
std::cin >> option_select;
viewMenu(Menus[option_select - 1]);
open_menu_options();
break;
}
case(4):{
std::cout << "Menus:\n";
int counter = 1;
for ( Menu i : Menus){
std::cout << counter << ". " << i.name << endl;
counter++;
}
std::cout << "Enter the number of the Menu you would like to remove or enter 0 to go back\n>> ";
std::cin >> option_select;
if (option_select != 0){
std::cout << "\n\n" << Menus[option_select - 1].name << " successfully deleted.\n\n";
Menus.erase(Menus.begin() + option_select - 1);
}
open_menu_options();
break;
}
case(5):{
writeFileData();
std::cin.clear();
open_inventory_options();
break;
}
default:{
std::cout << "Invalid input.\n";
open_menu_options();
break;
}
}
}
void MainMenu::open_order_options(){
std::cout << "1. View Completed Orders\n2. Go Back\n>> ";
std::cin >> option_select;
switch (option_select){
case(1): viewCompletedOrders(); break;
case(2): open_management_system_options(); break;
}
}
void MainMenu::open_waiter_options(){
std::cout << "1. Add New Waiter\n2. View Waiters\n3. Go Back\n";
std::cin >> option_select;
switch (option_select){
case(1):{
std::cout << "\n\nWhat is the name of the new waiter?\n>> ";
std::string name;
std::cin >> name;
Waiter newWaiter;
newWaiter.name = name;
Waiters.push_back(newWaiter);
std::cout << name << " added to Waiters.\n\n";
open_waiter_options();
break;
}
case(2):{
std::cout << "\t\tName\n";
for (Waiter w : Waiters){
std::cout << "\t\t" << w.name << endl;
}
std::cout << endl;
open_waiter_options();
break;
}
case(3): { open_management_system_options(); break;}
default:{
std::cout << "Invalid input.\n";
open_waiter_options();
break;
}
}
}
void MainMenu::open_discount_options(){
std::cout << "Select a Discount Option:\n";
std::cout << "1. Add New Discount\n2. Edit Discount\n3. View Discounts\n4. Delete Discount\n";
std::cout << "5. Go Back\n>> ";
std::cin >> option_select;
switch (option_select){
case(1):{
std::cout << "Enter the name of the discount:\n>> ";
std::string name;
std::cin >> name;
std::cout << "Enter the percentage amount of the discount:\n>> ";
double discountAmount;
std::cin >> discountAmount;
Discount tempDiscount(name, discountAmount);
}
case(5): { open_management_system_options(); break;}
default:{
std::cout << "Invalid input.\n";
open_discount_options();
break;
}
}
}
void open_seating_options(){
std::cout << "Select a Menu Option:\n";
}
void MainMenu::clearFile(std::string file){
std::fstream ofs;
ofs.open(file, std::ios::out | std::ios::trunc);
ofs.close();
}
void MainMenu::readFileData(){
loadIngredientData();
loadMenuOptionData();
loadMenuData();
}
void MainMenu::writeFileData(){
clearFile("Ingredient_data.txt");
for (Ingredient i : Ingredients){
saveIngredientData(i);
}
clearFile("MenuOption_data.txt");
clearFile("MenuOption_extraData.txt");
for (MenuOption m : MenuOptions){
saveMenuOptionData(m);
}
clearFile("Menu_data.txt");
clearFile("Menu_extraData.txt");
for (Menu m : Menus){
saveMenuData(m);
}
}
void MainMenu::loadIngredientData(){
std::ifstream fin;
fin.open("Ingredient_data.txt");
std::string name;
double cost;
double quantity;
while (fin >> name >> cost >> quantity){
Ingredient tempIngredient(name, cost, quantity);
Ingredients.push_back(tempIngredient);
}
}
void MainMenu::loadMenuOptionData(){
std::ifstream fin;
fin.open("MenOp.txt");
MenuOption tempMenuOption;
while (fin >> tempMenuOption){
MenuOptions.push_back(tempMenuOption);
}
fin.close();
std::ifstream fin2;
fin2.open("MenuOption_extraData.txt");
int counter = 0;
std::string str;
while (!fin2.eof()){
std::getline(fin2, str);
std::vector<std::string> tempIngredients = createVector(str);
for(std::string str : tempIngredients){
MenuOptions[counter].Ingredients.push_back(str);