-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.cpp
331 lines (303 loc) · 10.3 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
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
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <ctype.h>
#include <cstdlib>
#include <windows.h>
#include <unistd.h>
#include <time.h>
#include "Costumer.h"
#include "Floors.h"
using namespace std;
/*
Prototypes
*/
void TimeDelay();
void deleteDataInFile();
void deleteBottlesInFile();
void takeCommand();
void homeMenu();
///global variables and arrays_start
int costumerNumber = 0;
//General structure of an array = {room number , Empty == true , number of people}
//Rooms of the 3 floors of the hotel
int roomsFloor1[10][3] = {{101, false,2}, {102, true,1}, {103, true,4}, {104, true,2}, {105, true,3}, {106, true,5}, {107, true,4}, {108, true,1}, {109, true,4}, {110, true,4}};
int roomsFloor2[10][3] = {{201, false,3}, {202, false,2}, {203, true,2}, {204, true,4}, {205, true,1}, {206, true,4}, {207, true,3}, {208, true,4}, {209, true,5}, {210, true,3}};
int roomsFloor3[10][3] = {{301, false,4}, {302, false,5}, {303, false,4}, {304, true,5}, {305, true,2}, {306, true,3}, {307, true,1}, {308, true,2}, {309, true,3}, {310, true,2}};
//arrays
string roomBookedForCostumersName[50];
int roomBookedForCostumersRoom[50];
int roomBookedForCostumersBottle[50];
int roomBookedForCostumersBottlesDrank[50];
int roomBookedForCostumersBill[50];
///global variables and arrays_end
int main()
{
deleteDataInFile(); //deletes the previous data in file
deleteBottlesInFile();
homeMenu(); //program starts
return 0;
}
void takeCommand()
{
int roomNumber;
system("cls");
Costumer c1;
Floors f1;
int command_1; //output screen
cout<<"---------------------------------------------------------"<<endl;
cout<<" Welcome to Pearl Continental "<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<""<<endl; //asks the user what kind of details he/she requires
cout<<" Type '1' to get details of a room"<<endl;
cout<<" Type '2' to get number of vacant rooms on a floor"<<endl;
cout<<" Type '3' to get total number of vacant rooms"<<endl;
cout<<" Type '4' to get bottles in the refrigerator of a customer"<<endl;
cout<<" Type '5' to get number of bottles guest drank"<<endl;
cout<<" Type '6' to get names of people living in hotel"<<endl;
cout<<" Type '7' to get all bottles used by guests"<<endl;
cout<<" Type '8' to navigate to homepage"<<endl;
cout<<""<<endl;
cout<<" Enter command: ";
cin>>command_1;
//gives the details according to what the user wants
if (command_1 == 1) //details of a room
{
int roomNumber;
cout<<"Enter room number: ";
cin>>roomNumber;
f1.getRoomInfo(roomNumber);
c1.peopleInRoom(roomNumber);
system("pause"); // says ,"Press any key to continue"
system("cls");
takeCommand();
}
else if (command_1 == 2) //number of vacant rooms on a floor
{
int room_i;
cout<<" Enter room number: ";
cin>>room_i;
f1.getAllRooms(room_i);
system("pause"); // says ,"Press any key to continue"
system("cls");
takeCommand();
}
else if (command_1 == 3) //total number of vacant rooms
{
f1.getAllRooms();
system("pause"); // says ,"Press any key to continue"
system("cls");
takeCommand();
}
else if (command_1 == 4) //bottles in the refrigerator of a customer
{
int roomNo_1;
cout<<"Enter your room number: ";
cin>>roomNo_1;
c1.getNoOfBottlesAvailable(roomNo_1);
system("pause"); // says ,"Press any key to continue"
system("cls");
takeCommand();
}
else if (command_1 == 5) //number of bottles guest drank
{
int roomNumber;
cout<<"Enter room number:";
cin>>roomNumber;
c1.getBottlesDrank(roomNumber);
system("pause"); // says ,"Press any key to continue"
system("cls");
takeCommand();
}
else if (command_1 == 6) //names of people living in hotel
{
cout<<""<<endl;
cout<<"People living in hotel: "<<costumerNumber<<endl;
cout<<""<<endl;
cout<<"-------------"<<endl;
cout<<""<<endl;
if (costumerNumber==0) //hotel is empty
{
cout<<"No one is living in the hotel "<<endl;
}
else
{
cout<<"-----------------------------------------------------------------------"<<endl;
for (int i = 0; i<costumerNumber; i++)
{
cout<<"-------------------------------"<<endl;
cout<<"Name: "<<roomBookedForCostumersName[i]<<" Room number: "<<roomBookedForCostumersRoom[i]<<endl;
cout<<""<<endl;
roomNumber = roomBookedForCostumersRoom[i];
f1.getRoomInfo(roomNumber);
c1.peopleInRoom(roomNumber);
}
}
system("pause"); // says ,"Press any key to continue"
system("cls");
takeCommand();
}
else if (command_1 ==7) //all bottles used by guests
{
c1.getBottlesFromFile();
system("pause"); // says ,"Press any key to continue"
system("cls");
takeCommand();
}
else if (command_1 == 8) //navigates back to homepage
{
system("cls");
homeMenu(); //again asks the user what to do
}
else
{
cout<<"Please enter a valid command."<<endl; //if the entered command is not valid
Sleep(633);
system("pause"); // says ,"Press any key to continue"
system("cls");
takeCommand();
}
}
void homeMenu()
{
srand (time(NULL));
Costumer c1; //object customer
Floors f1; //object room/floor
int days;
int totalEarned = 0;
int peopleEnteringHotel;
int noOfPeople = 0;
int takeBottleFromRoom = 0;
int takeBottleTimes = 0;
int takeAmountOfBottles = 0;
int numberOfCheckouts = 0;
int personToCheckout = 0;
string command;
//main menu
cout<<"---------------------------------------------------------"<<endl;
cout<<" Welcome to Pearl Continental "<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<""<<endl;
cout<<"Type 'sim' for simulation"<<endl;
cout<<"Type 'det' for details"<<endl;
cout<<"Type 'exit' to close program"<<endl;
cout<<""<<endl;
cout<<"What do you want to do? ";
cin>>command;
if (command == "exit")
{
exit(EXIT_SUCCESS); //closes the program
}
if (command == "det") //if the user want details then goes to takeCommand function
{
takeCommand();
}
if (command == "sim") //simulation
{
///day 1 simulation
cout<<"Number of days you want to simulate: "; //asks user for number of days
cin>>days; // generates at random
for (int i = 0 ; i< days ; i++)
{
cout<<"____________________________________________________________________________________________________________"<<endl;
cout<<""<<endl;
cout<<"--------------------------------------"<<endl;
cout<<" Guests in hotel - DAY "<<i+1<<" "<<endl;
c1.namesOfPeopleInHotel();
cout<<"--------------------------------------"<<endl;
peopleEnteringHotel = rand() % 5 + 1;
for (int i = 0 ; i< peopleEnteringHotel ; i++)
{
noOfPeople = rand() % 5 + 1;
Costumer c1(noOfPeople);
}
takeAmountOfBottles = rand() % 5 + 1;
takeBottleTimes = rand() % 5+2;
for (int i = 0 ; i<takeBottleTimes ; i++)
{
takeBottleFromRoom = rand() % costumerNumber;
for (int j = 0 ; j<takeAmountOfBottles ; j++)
{
c1.takeABottle(roomBookedForCostumersRoom[takeBottleFromRoom]);
totalEarned = totalEarned + 90;
}
}
cout<<"--------------------------------------"<<endl;
cout<<" BOTTLES DRANK "<<endl;
cout<<""<<endl;
for (int i = 0; i<costumerNumber ; i++)
{
c1.getBottlesDrank(roomBookedForCostumersRoom[i]);
}
//bills
cout<<"--------------------------------------"<<endl;
}
//bills
for (int i = 0; i<costumerNumber ; i++)
{
roomBookedForCostumersBill[i] = roomBookedForCostumersBill[i] + 5000;
totalEarned = totalEarned + 5000;
}
//random checkouts
numberOfCheckouts = rand() % (costumerNumber/2)+1;
for (int i = 0; i<numberOfCheckouts ; i++)
{
//person to checkout
personToCheckout = rand() % costumerNumber;
//person to checkout
c1.checkOut(roomBookedForCostumersName[personToCheckout],roomBookedForCostumersRoom[personToCheckout]);
}
cout<<"Hotel earned: Rs "<<totalEarned<<endl;
system("pause"); // says ,"Press any key to continue"
system("cls");
homeMenu();
}
else
{
cout<<"Give a valid command "<<endl; //if the program does not recognize the command given
Sleep(300);
system("cls");
homeMenu();
}
}
void TimeDelay() // gives a 3 second pause
{
cout<<""<<endl;
cout<<"1";
Sleep(333); //time in milliseconds
cout<<".";
Sleep(333); //time in milliseconds
cout<<".";
Sleep(331); //time in milliseconds
cout<<"2";
Sleep(333); //time in milliseconds
cout<<".";
Sleep(333); //time in milliseconds
cout<<".";
Sleep(331); //time in milliseconds
cout<<"3";
Sleep(333); //time in milliseconds
cout<<".";
Sleep(333); //time in milliseconds
cout<<".";
Sleep(331); //time in milliseconds
}
void deleteDataInFile()
{
string editLine; // takes each line
ofstream editFile;
char filename[30] = "Datafile.txt";
editFile.open(filename);
editFile<<""<<endl; //deletes entire data in file
editFile.close();
}
void deleteBottlesInFile()
{
string editLine; // takes each line
ofstream editFile;
char filename[30] = "Bottlefile.txt";
editFile.open(filename); //deletes all the data stored in file
editFile<<""<<endl;
editFile.close();
}