-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
410 lines (266 loc) · 5.71 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
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
//DEVELOPED BY Nemonet TYP
//C++ PROJECT
//START OF THE PROGRAM FOR HOTEL MANAGEMENT
#include<iostream>
//#include<conio.h>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
//#include<dos.h>
using namespace std;
//START OF CLASS
class hotel
{
int room_no;
char name[30];
char address[50];
char phone[10];
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 alloted 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 bill(int); //for the bill of a record
};
//END OF CLASS
//FOR DISPLAYING MAIN MENU
void hotel::main_menu()
{
int choice;
while(choice!=5)
{
system("cls");
cout<<"\n\t\t\t\t**************************";
cout<<"\n\t\t\t\t SIMPLE HOTEL MANAGEMENT ";
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 Records";
cout<<"\n\t\t\t3.Rooms Allotted";
cout<<"\n\t\t\t4.Edit Record";
cout<<"\n\t\t\t5.Exit";
cout<<"\n\n\t\t\tEnter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1: add();
break;
case 2: display();
break;
case 3: rooms();
break;
case 4: edit();
break;
case 5: break;
default:
{
cout<<"\n\n\t\t\tWrong choice.....!!!";
cout<<"\n\t\t\tPress any key to continue....!!";
//getch();
}
}
}
}
//END OF MENU FUNCTION
//FUNCTION FOR BOOKING OF ROOM
void hotel::add()
{
system("cls");
int r,flag;
ofstream fout("Record.dat",ios::app);
cout<<"\n Enter Customer Detalis";
cout<<"\n -----------------------";
cout<<"\n\n Room no: ";
cout<<"\n Total no. of Rooms - 50";
cout<<"\n Ordinary Rooms from 1 - 30";
cout<<"\n Luxury Rooms from 31 - 45";
cout<<"\n Royal Rooms from 46 - 50";
cout <<"\n Enter The Room no. you want to stay in :- "<<'\n';
cin>>r;
flag=check(r);
if(flag)
cout<<"\n Sorry..!!!Room is already booked";
else
{
room_no=r;
cout<<" Name: ";
cin>>name;
cout<<" Address: ";
cin>>address;
cout<<" Phone No: ";
cin>>phone;
fout.write((char*)this,sizeof(hotel));
cout<<"\n Room is booked...!!!";
}
cout<<"\n Press any key to continue.....!!";
//getch();
fout.close();
}
//END OF BOOKING FUNCTION
//FUNCTION FOR DISPLAYING A PURTICULAR CUSTOMER`S RECORD
void hotel::display()
{
system("cls");
ifstream fin("Record.dat",ios::in);
int r,flag;
cout<<"\n Enter room No. for a particular customer`s details :- "<<'\n';
cin>>r;
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{
system("cls");
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;
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry Room no. not found or vacant....!!";
cout<<"\n\n Press any key to continue....!!";
//getch();
fin.close();
}
//END OF DISPLAY FUNCTION
//FUNCTION TO DISPLAY ALL ROOMS OCCUPIED
void hotel::rooms()
{
system("cls");
ifstream fin("Record.dat",ios::in);
cout<<"\n\t\t\t List Of Rooms Allotted";
cout<<"\n\t\t\t -----------------------";
cout<<"\n\n Room No.\tName\t\tAddress\t\t\t\tPhone No.\n";
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
cout<<"\n\n "<<room_no<<"\t\t"<<name;
cout<<"\t\t"<<address<<"\t\t"<<phone;
}
cout<<"\n\n\n\t\t\tPress any key to continue.....!!";
//getch();
fin.close();
}
//FUNCTION FOR EDITING RECORDS AND FOR BILL
void hotel::edit()
{
system("cls");
int choice,r;
cout<<"\n EDIT MENU";
cout<<"\n ----------";
cout<<"\n\n 1. Modify Customer Record";
cout<<"\n 2. Delete Customer Record";
cout<<"\n 3. Bill Of Customer";
cout<<"\n Enter your choice: ";
cin>>choice;
system("cls");
cout<<"\n Enter room no: " ;
cin>>r;
switch(choice)
{
case 1: modify(r);
break;
case 2: delete_rec(r);
break;
case 3: bill(r);
break;
default: cout<<"\n Wrong Choice.....!!";
}
cout<<"\n Press any key to continue....!!!";
//getch();
}
int hotel::check(int r)
{
int flag=0;
ifstream fin("Record.dat",ios::in);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{
flag=1;
break;
}
}
fin.close();
return(flag);
}
//FUNCTION TO MODIFY CUSTOMERS RECORD
void hotel::modify(int r)
{
/* long pos,flag=0;
fstream file("Record.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
pos=file.tellg();
file.read((char*)this,sizeof(hotel)); */
cout<< "Enter your code here";
}
//END OF MODIFY FUNCTION
//FUNCTION FOR DELETING RECORD
void hotel::delete_rec(int r)
{
/* int flag=0;
char ch;
ifstream fin("Record.dat",ios::in);
ofstream fout("temp.dat",ios::out);
*/
cout<< "enter your code here";
}
//END OF DELETE FUNCTION
//FUNCTION FOR CUSTOMER`S BILL
void hotel::bill(int r)
{
hotel h1;
ifstream f1;
f1.open("record.dat",ios::in|ios::binary);
if(!f1)
cout<<"cannot open";
else
{
f1.read((char*)&h1,sizeof (hotel));
while(f1)
{
f1.read((char*)&h1,sizeof(hotel));
}
if (h1.room_no == r)
{
if(h1.room_no>=1&&h1.room_no<=30)
cout<<"your bill = 2000";
else if (h1.room_no>=35&&h1.room_no<=45)
cout<<"your bill = 5000" ;
else
cout<<"your bill = 7000";
}
else
{ cout<<"room no. not found";}
}
f1.close();
//getch();
}
//END OF BILLING FUNCTION
//START OF MAIN PROGARM
int main()
{
hotel h;
system("cls");
cout<<"\n\t\t\t*****************************";
cout<<"\n\t\t\t* HOTEL MANAGEMENT PROJECT *";
cout<<"\n\t\t\t*****************************";
cout<<"\n\n\t\tDeveloped By:";
cout<<"\n\t\t\t\t The Young Programmer (TYP)";
cout<<"\n\n\n\n\n\n\n\t\t\t\t\tPress any key to continue....!!";
//getch();
h.main_menu();
return 0;
}
//END OF MAIN PROGRAM