-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
126 lines (114 loc) · 3.45 KB
/
Copy pathmain.cpp
File metadata and controls
126 lines (114 loc) · 3.45 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
#include <iostream>
#include <fstream>
#include <string>
#include <limits>
#include "admin.cpp"
#include "design.cpp"
#include "menu.cpp"
#include "rooms.cpp"
using namespace std;
class MainHotel
{
public:
void showBuffetOptions();
void start();
};
void MainHotel::start()
{
Hotel hotel;
hotel.displayFront();
Reservation roomManagement; // Composition
Cancellation cancelManager;
Manager manager;
int choice;
do
{
roomManagement.initializeRooms();
cout << "\n1. Reserve a room\n";
cout << "2. Cancel a room\n";
cout << "3. Buffet option\n";
cout << "4. Show room status\n";
cout << "5. Login as manager\n";
cout << "6. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
while (cin.fail() || choice < 1 || choice > 6)
{
cin.clear(); // Clear the error state
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "\nPlease enter a valid choice (1-6): ";
cin >> choice;
}
switch (choice) {
case 1:
roomManagement.reserveRoom();
break;
case 2:
cancelManager.cancelRoom(roomManagement);
break;
case 3:
showBuffetOptions();
break;
case 4:
roomManagement.showRoomStatus();
break;
case 5:
manager.login();
break;
case 6:
cout << "Exiting the program." << endl;
break;
}
} while (choice != 6);
}
void MainHotel::showBuffetOptions() {
int menuChoice;
Appetizer appetizer;
Sandwiches sandwiches;
Continental continental;
Chinese chinese;
Desserts desserts;
cout << "Here is our buffet list:\n";
cout << "1. Appetizer for 5$\n";
cout << "2. Sandwiches for 6$\n";
cout << "3. Continental food for 7$\n";
cout << "4. Chinese for 9$\n";
cout << "5. Desserts for 8$\n";
cout << "6. Exit\n";
cout << "Enter your choice: ";
cin >> menuChoice;
while (cin.fail() || menuChoice < 1 || menuChoice > 6)
{
cin.clear(); // Clear the error state
cin.ignore(numeric_limits<streamsize>::max(), '\n'); // Discard invalid input
cout << "Invalid choice. Please enter a valid choice (1-6): ";
cin >> menuChoice;
}
switch (menuChoice) {
case 1:
processMenu(appetizer); // Call Appetizer
break;
case 2:
processMenu(sandwiches); // Call Sandwiches
break;
case 3:
processMenu(continental); // Call Continental
break;
case 4:
processMenu(chinese); // Call Chinese
break;
case 5:
processMenu(desserts); // Call Desserts
break;
case 6:
return; // Exit the function
default:
cout << "Invalid choice." << endl;
break;
}
}
int main() {
MainHotel mainHotel;
mainHotel.start();
return 0;
}