-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHotelManagementProject.cpp
More file actions
648 lines (567 loc) · 16.6 KB
/
HotelManagementProject.cpp
File metadata and controls
648 lines (567 loc) · 16.6 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
#pragma once
#pragma warning(disable : 4996)
#include <iostream>
#include<fstream>
#include<stdio.h>
#include<string.h>
using namespace std;
#define R 5
#define C 40
enum { Red = 1, Blue, Purple, Turquoise, Pink };
enum { Bachelor = 1, Bachelorette };
class hotel
{
int room_no;
char name[30];
char address[50];
char phone[10];
int breakfast;
int num_of_person_restaurant;
static int num_of_possible_reservation;
static int clean;
static int count;
public:
void main_menu(); //to display the main menu
void add(); //to book a room
void display(); //to display the customer record
void rooms(); //to display allotted rooms
void edit(); //to edit the customer record
int check(int); //to check room status
void modify(int); //to modify the record
void delete_rec(int); //to delete the record
void feedbacks(int**, char**); // to leave a feedback
void addfeedback(int**, char**); //to add feedback
void printfeedbacks(int**, char**); // to display feedbacks
void housekeeping(); // to check if a room is clean or to ask for cleaning
bool room_design(int); //to choose room design
void restaurant(); //to see number of table
};
int hotel::count = 0;
int hotel::clean = 1;
int hotel::num_of_possible_reservation = 150;
void hotel::main_menu()
{
int** rates = new int* [C];
for (int i = 0; i < C; i++)
{
rates[i] = new int[R];
}
char** names = new char* [C];
int choice = 0;
while (choice != 8)
{
cout << "\n\t\t\t\t*************";
cout << "\n\t\t\t\t* MAIN MENU *";
cout << "\n\t\t\t\t*************";
cout << "\n\n\n\t\t\t1.Book A Room";
cout << "\n\t\t\t2.Customer Record";
cout << "\n\t\t\t3.Rooms Allotted";
cout << "\n\t\t\t4.Edit Record";
cout << "\n\t\t\t5.Feedback";
cout << "\n\t\t\t6.Housekeeping";
cout << "\n\t\t\t7.Restaurant";
cout << "\n\t\t\t8.Exit";
cout << "\n\n\t\t\t Enter Your Choice: ";
cin >> choice;
switch (choice)
{
case 1: add();
break;
case 2: display();
break;
case 3: rooms();
break;
case 4: edit();
break;
case 5:
{
feedbacks(rates, names);
break;
}
case 6: housekeeping();
break;
case 7: restaurant();
break;
case 8: break;
default:
{
cout << "\n\n\t\t\tWrong choice!";
cout << "\n\t\t\tPress any key to continue..";
getchar();
}
}
}
}
bool hotel::room_design(int age)
{
cout << "\n Choose desired design: " << endl;
cout << "1. Birthday party design" << endl;
cout << "2. Surprise party design" << endl;
cout << "3. Bachelor/Bachelorette party design " << endl;
cout << "4. Honeymoon design " << endl;
int design;
cin >> design;
if (design < 1 || design>4)
{
return false;
}
if (design == 3 || design == 4 && age < 18)
{
return false;
//Can not choose these designs if under 18
}
switch (design)
{
case 1:
{
int color;
cout << "Choose age baloons color " << endl;
cout << "1. Red" << endl;
cout << "2. Blue" << endl;
cout << "3. Purple " << endl;
cout << "4. Turquoise " << endl;
cout << "5. Pink " << endl;
cin >> color;
if (color<Red || color> Pink)
{
cout << " Sorry, you selected a non-existent color " << endl;
return false;
}
break;
}
case 2:
{
unsigned int guests;
cout << "Enter number of guests: " << endl;
cin >> guests;
if (guests > 30)
{
cout << " Sorry, room can contain up to 30 guests only. " << endl;
return false;
}
break;
}
case 3:
{
int gender;
unsigned int guests;
cout << "Press [1] for Bachelor party design " << endl <<
"Press [2] for Bachelorette party design" << endl;
cin >> gender;
cout << "Enter number of guests " << endl;
cin >> guests;
if (guests > 30)
{
cout << " Sorry, room can contain up to 30 guests only " << endl;
return false;
}
if (gender == Bachelor)
{
cout << "Enter number of guests (male only): " << endl;
cin >> guests;
cout << "We will prepare " << guests * 5 << " beers for you." << endl;
}
if (gender == Bachelorette)
{
cout << "Enter number of guests (female only): " << endl;
cin >> guests;
cout << "We will prepare " << guests * 3 << " cocktails for you." << endl;
}
break;
}
case 4:
{
int petals;
cout << " Choose rose petals color: " << endl;
cout << "1. Red" << endl;
cout << "2. Blue" << endl;
cout << "3. Purple " << endl;
cout << "4. Turquoise " << endl;
cout << "5. Pink " << endl;
cin >> petals;
if (petals != Red)
{
cout << "Sorry, we have only red rose petals." << endl;
return false;
}
break;
}
default:
cout << "Wrong input" << endl;
return false;
break;
}
return true;
}
void hotel::feedbacks(int** rates, char** names)
{
int choice;
cout << "\n -------";
cout << "\n\n 1.Add a feedback";
cout << "\n 2.Display all previous feedbacks";
cout << "\n\n Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1: addfeedback(rates, names);
break;
case 2: printfeedbacks(rates, names);
break;
default:
{
cout << "\n Wrong Choice!";
cout << "\n Press any key to continue!";
}
}
}
void hotel::addfeedback(int** rates, char** names)
{
int rate;
char name[20];
int number;
cout << "\n --------";
cout << "\nEnter your name: ";
cin >> name;
names[count] = new char[strlen(name) + 1];
strcpy(names[count], name);
cout << "\n --------";
cout << "Rate on a scale of 1-5";
cout << "\nCleanliness: ";
cin >> rate;
rates[count][0] = rate;
cout << "\nHotel staff: ";
cin >> rate;
rates[count][1] = rate;
cout << "\nCheck-in waiting time: ";
cin >> rate;
rates[count][2] = rate;
cout << "\nFood: ";
cin >> rate;
rates[count][3] = rate;
cout << "\nRecommend the hotel to others: ";
cin >> rate;
rates[count][4] = rate;
count++;
cout << "\nThank you for your time!\n";
}
void hotel::printfeedbacks(int** rates, char** names)
{
for (int i = 0; i < count; i++)
{
cout << "\nName: " << names[i] << endl;
cout << "Cleanliness: " << rates[i][0] << "\t";
cout << "Hotel staff: " << rates[i][1] << "\t";
cout << "Check-in waiting time: " << rates[i][2] << "\t";
cout << "Food: " << rates[i][3] << "\t";
cout << "Recommend the hotel to others: " << rates[i][4] << "\n";
}
if (!count)
{
cout << "No feedback for the moment.\n";
}
}
void hotel::add()
{
int r, flag;
ofstream fout("Record", ios::binary | ios::app);
cout << "\n Enter Customer Details";
cout << "\n --------";
cout << "\n\n Room no: ";
cin >> r;
flag = check(r);
if (flag)
{
cout << "\n Sorry! Room is already booked.";
}
else
{
char design;
int age, num_choice, num;
room_no = r;
cout << " Name: ";
cin >> name;
cout << " Address: ";
cin >> address;
cout << " Phone No: ";
cin >> phone;
// Validate breakfast input
cout << " Eats breakfast (Yes (1) / No (0)) : ";
while (!(cin >> breakfast) || (breakfast != 1 && breakfast != 0)) {
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Invalid input. Please enter 1 for Yes or 0 for No: ";
}
cout << " Guest age : ";
cin >> age;
cout << " Does " << name << " need some special design of the room?\n"
<< "[1]-Yes\n[Any other key]-No\n";
cin >> design;
if (design == '1')
{
if (room_design(age))
{
cout << "The request for special design was successfully processed.\n"
<< "Price of the service is 50$.\n";
}
else
{
cout << "An error occurred\n"
<< "The request to design the room was rejected\n";
}
}
cout << " Reservation for the restaurant (Yes (1) / No (0)): ";
while (!(cin >> num_choice) || (num_choice != 1 && num_choice != 0)) {
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Invalid input. Please enter 1 for Yes or 0 for No: ";
}
if (num_choice == 0)
num_of_person_restaurant = 0;
else if (num_choice == 1)
{
cout << "How many people for reservation? ";
while (!(cin >> num) || num < 0) {
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Invalid input. Please enter a valid number: ";
}
if (num < num_of_possible_reservation)
{
num_of_person_restaurant = num;
num_of_possible_reservation -= num;
}
else
{
cout << "Too many people, not enough space available.\n";
num_of_person_restaurant = 0;
}
}
fout.write((char*)this, sizeof(hotel));
cout << "\n Room is booked!";
}
fout.close();
cout << "\n\n Press any key to continue!";
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin.get();
}
void hotel::display()
{
ifstream fin("Record", ios::in);
int r, flag = 0;
cout << "\n Enter room no: ";
cin >> r;
while (!fin.eof())
{
fin.read((char*)this, sizeof(hotel));
if (room_no == r)
{
cout << "\n Customer Details";
cout << "\n -------";
cout << "\n\n Room no: " << room_no;
cout << "\n Name: " << name;
cout << "\n Address: " << address;
cout << "\n Phone no: " << phone;
cout << "\n Number of people for restaurant: " << num_of_person_restaurant;
if (clean == 1)
cout << "\n Housekeeping : The room is clean.";
else
cout << "\n Housekeeping : Not clean.";
if (breakfast)
cout << "\n Eats breakfast at hotel";
else
cout << "\n No breakfast at hotel";
flag = 1;
break;
}
}
if (!flag)
cout << "\n Sorry Room no. not found or empty!";
cout << "\n\n Press any key to continue!";
getchar();
fin.close();
}
void hotel::rooms()
{
ifstream fin("Record", ios::binary);
cout << "\n\t\t\t List Of Rooms Allotted";
cout << "\n\t\t\t -------";
cout << "\n\n Room No.\tName\t\tAddress\t\tPhone No.\t\tBreakfast";
while (fin.read((char*)this, sizeof(hotel)))
{
cout << "\n\n " << room_no << "\t\t" << name;
cout << "\t\t" << address << "\t\t" << phone;
if (breakfast)
cout << "\t\t\tEats breakfast";
else
cout << " \t\t\tNo breakfast";
}
fin.close();
cout << "\n\n\n\t\t\tPress any key to continue!";
cin.ignore();
cin.get();
}
void hotel::edit()
{
int choice, r;
cout << "\n EDIT MENU";
cout << "\n -------";
cout << "\n\n 1.Modify Customer Record";
cout << "\n 2.Delete Customer Record";
cout << "\n Enter your choice: ";
cin >> choice;
cout << "\n Enter Room no: ";
cin >> r;
switch (choice)
{
case 1: modify(r);
break;
case 2: delete_rec(r);
break;
default: cout << "\n Wrong Choice!";
}
cout << "\n Press any key to continue!";
getchar();
}
int hotel::check(int r)
{
int flag = 0;
ifstream fin("Record", ios::in);
while (!fin.eof())
{
fin.read((char*)this, sizeof(hotel));
if (room_no == r)
{
flag = 1;
break;
}
}
fin.close();
return(flag);
}
void hotel::modify(int r)
{
long pos, flag = 0;
fstream file("Record", ios::in | ios::out | ios::binary);
while (!file.eof())
{
pos = file.tellg(); //returns the position
file.read((char*)this, sizeof(hotel));
if (room_no == r)
{
cout << "\n Enter New Details";
cout << "\n -------";
cout << "\n Name: ";
cin >> name;
cout << " Address: ";
cin >> address;
cout << " Phone no: ";
cin >> phone;
cout << " Eats breakfast (Yes (1) / No (0) : ";
cin >> breakfast;
clean = 0;
cout << "Modify your reservation in restaurant. How many people are you?";
num_of_possible_reservation = num_of_possible_reservation + num_of_person_restaurant;
cin >> num_of_person_restaurant;
num_of_possible_reservation = num_of_possible_reservation - num_of_person_restaurant;
file.seekg(pos);
file.write((char*)this, sizeof(hotel));
cout << "\n Record has been modified!";
flag = 1;
break;
}
}
if (flag == 0)
cout << "\n Sorry Room no. not found or empty!";
file.close();
}
void hotel::delete_rec(int r)
{
int flag = 0;
char ch;
ifstream fin("Record", ios::binary);
ofstream fout("temp", ios::binary);
while (fin.read((char*)this, sizeof(hotel)))
{
if (room_no == r && !flag) // Add !flag to prevent multiple prompts
{
cout << "\n Name: " << name;
cout << "\n Address: " << address;
cout << "\n Phone No: " << phone;
cout << "\n Table in restaurant: " << num_of_person_restaurant;
cout << "\n\n Do you want to delete this record(y/n): ";
cin >> ch;
if (ch == 'n')
fout.write((char*)this, sizeof(hotel));
flag = 1;
}
else
fout.write((char*)this, sizeof(hotel));
}
fin.close();
fout.close();
if (flag == 0)
cout << "\n Sorry room no. not found or empty!";
else
{
remove("Record");
rename("temp", "Record");
}
}
void hotel::housekeeping()
{
ifstream fin("Record", ios::in);
int r, flag = 0, choice;
cout << "\n Please enter a room number: ";
cin >> r;
while (!fin.eof())
{
fin.read((char*)this, sizeof(hotel));
if (room_no == r)
{
if (clean)
{
cout << "\n The room is already clean.";
flag = 1;
break;
}
else
cout << "\n The room is not clean. Do you want to send housekeeper ? ( Yes(1) / No(0) ): ";
cin >> choice;
if (choice == 1)
{
cout << "\n We've sent the housekeeper to clean your room.";
clean++;
flag = 1;
break;
}
if (choice == 0)
{
flag = 1;
break;
}
}
}
if (flag == 0)
{
cout << "\n The room doesn't exist.";
}
cout << "\n\n Press any key to continue!";
getchar();
fin.close();
}
void hotel::restaurant()
{
cout << "\n Number of places available in the restaurant : " << num_of_possible_reservation;
if (num_of_possible_reservation == 0)
{
cout << "\nUnfortunately ,no more place available,sorry.\n ";
}
cout << "\n\n Press any key to continue!";
getchar();
}
int main()
{
hotel h;
h.main_menu();
getchar();
}