📄 hotel_managment.cpp
字号:
//**********************************************************
// PROJECT : HOTEL MANAGEMENT SYSTEM
// PASSWORD : hms
//**********************************************************
//**********************************************************
// INCLUDED HEADER FILES
//**********************************************************
#include <iostream.h>
#include <conio.h>
#include <dos.h>
#include <string.h>
#include <fstream.h>
#include <process.h>
#include <stdio.h>
#include <ctype.h>
//**********************************************************
// CLASS NAME : MENU
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
//**********************************************************
class menu
{
public :
void main_menu(void) ;
void enter_password(void) ;
private :
void edit_menu(void) ;
void report_menu(void) ;
void room_edit_menu(void) ;
void customer_edit_menu(void) ;
} ;
//**********************************************************
// CLASS NAME : ROOM
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
// RELATED TO ROOM
//**********************************************************
class room
{
public :
void add (void) ;
void modify(void) ;
void deletion(void) ;
void display_room_record(void) ;
void display_list(void) ;
int room_found( int ) ;
void change_status(int,char) ;
char room_status(int) ;
float get_data(int) ;
private :
int recordno(int) ;
void display_record(int) ;
int roomno ;
char roomcode[5] , status ;
float tarriff ;
} ;
//**********************************************************
// CLASS NAME : CUSTOMER
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
// RELATED TO CUSTOMER
//**********************************************************
class customer
{
public :
void checkin (void) ;
void checkout (void) ;
void modify(void) ;
void deletion(void) ;
void display_list(void) ;
void display_customer_record(void) ;
private :
int recordno(int) ;
void display_record(int) ;
void delete_record(int) ;
int roomno ;
char name[21] , phone[8] ;
float advance , misc , room_srv ;
} ;
//**********************************************************
// CLASS NAME : ACCOUNT
// DETAILS : IT CONTROLLS OVER ALL THE FUNCTIONS
// RELATED TO PREPARATION OF BILL
//**********************************************************
class account
{
public :
void prepare_bill(int, float, char t_name[21], float, float, float) ;
} ;
//**********************************************************
// CLASS NAME : MENU
// FUNCTION NAME : ENTER_PASSWORD
// DETAILS : IT ACCEPTS THE PASSWORD AND TERMINATES
// THE PROGRAM IF WRONG ENTERED
//**********************************************************
void menu :: enter_password()
{
clrscr() ;
char pass1, pass2, pass3 ;
gotoxy(30,12) ;
cout <<"Enter the password : " ;
pass1 = getch() ;
cout <<"*" ;
pass2 = getch() ;
cout <<"*" ;
pass3 = getch() ;
cout <<"*" ;
sound(500) ;
delay(100) ;
nosound() ;
if (pass1 == 'h' && pass2 == 'm' && pass3 == 's')
return ;
gotoxy(30,12) ;
cout <<" WRONG PASSWORD " ;
gotoxy(2,1) ;
getch() ;
exit(0) ;
}
//**********************************************************
// CLASS NAME : MENU
// FUNCTION NAME : MAIN_MENU
// DETAILS : IT CREATE MAIN MENU TO CONTROLL
// FUNCTIONS
//**********************************************************
void menu :: main_menu(void)
{
char ch ;
char h[] = {"HOTEL"} ;
char m[] = {"MANAGEMENT"} ;
int j ;
while(1)
{
clrscr() ;
j = 9 ;
for (int i=0; h[i]!='\0'; i++)
{
gotoxy(15,j) ;
j++ ;
cout <<h[i] ;
}
j = 7 ;
for (i=0; m[i]!='\0'; i++)
{
gotoxy(65,j) ;
j++ ;
cout <<m[i] ;
}
gotoxy(30,5) ;
cout <<"1. CHECK IN" ;
gotoxy(30,7) ;
cout <<"2. CHECK OUT" ;
gotoxy(30,9) ;
cout <<"3. CUSTOMER RECORD" ;
gotoxy(30,11) ;
cout <<"4. ROOM RECORD" ;
gotoxy(30,13) ;
cout <<"5. EDIT" ;
gotoxy(30,15) ;
cout <<"6. REPORT" ;
gotoxy(30,17) ;
cout <<"0. EXIT TO DOS" ;
gotoxy(30,20) ;
cout <<"Enter your choice : " ;
ch = getch() ;
if ( ch == '1' )
{
customer c ;
c.checkin() ;
}
else
if ( ch == '2' )
{
customer c ;
c.checkout() ;
}
if ( ch == '3' )
{
customer c ;
c.display_customer_record() ;
}
else
if ( ch == '4' )
{
room r ;
r.display_room_record() ;
}
else
if ( ch == '5' )
edit_menu() ;
else
if ( ch == '6' )
report_menu() ;
else
if ( ch == '0' )
break ;
}
}
//**********************************************************
// CLASS NAME : MENU
// FUNCTION NAME : EDIT_MENU
// DETAILS : IT CREATE EDIT MENU TO CONTROLL
// FUNCTIONS OF ROOM & CUSTOMER CLASSES
//**********************************************************
void menu :: edit_menu(void)
{
char ch ;
while(1)
{
clrscr() ;
gotoxy(30,6) ;
cout <<" EDIT" ;
gotoxy(30,8) ;
cout <<"1. ROOM RECORDS" ;
gotoxy(30,10) ;
cout <<"2. CUSTOMER RECORDS" ;
gotoxy(30,12) ;
cout <<"0. EXIT" ;
gotoxy(30,15) ;
cout <<"Enter your choice : " ;
ch = getch() ;
if ( ch == '1' )
room_edit_menu() ;
else
if ( ch == '2' )
customer_edit_menu() ;
else
if ( ch == '0' )
break ;
}
}
//**********************************************************
// CLASS NAME : MENU
// FUNCTION NAME : ROOM_EDIT_MENU
// DETAILS : IT CREATE EDIT MENU TO CONTROLL
// FUNCTIONS OF ROOM CLASS
//**********************************************************
void menu :: room_edit_menu(void)
{
char ch ;
while(1)
{
clrscr() ;
gotoxy(30,8) ;
cout <<"1. ADD ROOM RECORDS" ;
gotoxy(30,10) ;
cout <<"2. MODIFY ROOM RECORDS" ;
gotoxy(30,12) ;
cout <<"3. DELETE ROOM RECORDS" ;
gotoxy(30,14) ;
cout <<"0. EXIT" ;
gotoxy(30,17) ;
cout <<"Enter your choice : " ;
ch = getch() ;
if ( ch == '1' )
{
room r ;
r.add() ;
}
else
if ( ch == '2' )
{
room r ;
r.modify() ;
}
else
if ( ch == '3' )
{
room r ;
r.deletion() ;
}
else
if ( ch == '0' )
break ;
}
}
//**********************************************************
// CLASS NAME : MENU
// FUNCTION NAME : CUSTOMER_EDIT_MENU
// DETAILS : IT CREATE EDIT MENU TO CONTROLL
// FUNCTIONS OF CUSTOMER CLASS
//**********************************************************
void menu :: customer_edit_menu(void)
{
char ch ;
while(1)
{
clrscr() ;
gotoxy(30,8) ;
cout <<"1. MODIFY CUSTOMER RECORDS" ;
gotoxy(30,10) ;
cout <<"2. DELETE CUSTOMER RECORDS" ;
gotoxy(30,12) ;
cout <<"0. EXIT" ;
gotoxy(30,15) ;
cout <<"Enter your choice : " ;
ch = getch() ;
if ( ch == '1' )
{
customer c ;
c.modify() ;
}
else
if ( ch == '2' )
{
customer c ;
c.deletion() ;
}
else
if ( ch == '0' )
break ;
}
}
//**********************************************************
// CLASS NAME : MENU
// FUNCTION NAME : REPORT_MENU
// DETAILS : IT CREATE REPORT MENU TO DISPLAY THE
// REPORT OF ROOMS AND CUSTOMERS
//**********************************************************
void menu :: report_menu(void)
{
char ch ;
while(1)
{
clrscr() ;
gotoxy(30,8) ;
cout <<"1. LIST OF ROOMS" ;
gotoxy(30,10) ;
cout <<"2. LIST OF CUSTOMERS" ;
gotoxy(30,12) ;
cout <<"0. EXIT" ;
gotoxy(30,15) ;
cout <<"Enter your choice : " ;
ch = getch() ;
if ( ch == '1' )
{
room r ;
r.display_list() ;
}
else
if ( ch == '2' )
{
customer c ;
c.display_list() ;
}
else
if ( ch == '0' )
break ;
}
}
//**********************************************************
// CLASS NAME : ROOM
// FUNCTION NAME : ROOM_FOUND
// DETAILS : IT RETURNS THE VALUE 1 IF GIVEN ROOM
// NO. FOUND
//**********************************************************
int room :: room_found ( int t_roomno )
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(room)))
{
if ( roomno == t_roomno )
found = 1 ;
}
file.close() ;
return found ;
}
//**********************************************************
// CLASS NAME : ROOM
// FUNCTION NAME : DISPLAY_LIST
// DETAILS : IT DISPLAYS THE LIST OF THE ROOM
//**********************************************************
void room :: display_list (void)
{
clrscr() ;
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int row = 5 , found = 0 , pageno = 1 ;
gotoxy(18,1) ;
cout <<"LIST OF ROOMS" ;
gotoxy(1,3) ;
cout <<" Room code Room no. Status Tarriff " ;
while (file.read((char *) this, sizeof(room)))
{
delay(20) ;
found = 1 ;
gotoxy(2,row) ;
cout<<roomcode ;
gotoxy(16,row) ;
cout<<roomno ;
gotoxy(29,row) ;
cout<<status ;
gotoxy(42,row) ;
cout<<tarriff ;
if ( row == 23 )
{
row = 5 ;
gotoxy(66,1) ;
cout <<"Page no. : " <<pageno ;
pageno++ ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
clrscr() ;
gotoxy(18,1) ;
cout <<"LIST OF ROOMS" ;
gotoxy(1,3) ;
cout <<" Room code Room no. Status Tarriff " ;
}
else
row++ ;
}
if ( !found )
{
sound(500) ;
delay(100) ;
nosound() ;
gotoxy(1,5) ;
cout <<"Records not found" ;
}
gotoxy(66,1) ;
cout <<"Page no. : " <<pageno ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
file.close () ;
}
//**********************************************************
// CLASS NAME : ROOM
// FUNCTION NAME : RECORDNO
// DETAILS : IT RETURNS THE RECORD NO. OF THE GIVEN
// ROOM NO.
//**********************************************************
int room :: recordno(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int count = 0 ;
while (file.read((char *) this, sizeof(room)))
{
count++ ;
if (t_roomno == roomno)
break ;
}
file.close() ;
return count ;
}
//**********************************************************
// CLASS NAME : ROOM
// FUNCTION NAME : DISPLAY_RECORD
// DETAILS : IT DISPLAYS THE RECORD OF THE GIVEN
// ROOM NO.
//**********************************************************
void room :: display_record(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
while (file.read((char *) this, sizeof(room)) && !found)
{
if (t_roomno == roomno)
{
found = 1 ;
gotoxy(1,5) ;
cout <<"Room code : " <<roomcode ;
gotoxy(1,6) ;
cout <<"Room no. : " <<roomno ;
gotoxy(1,7) ;
cout <<"Status : " <<status ;
gotoxy(1,8) ;
cout <<"Tarriff : " <<tarriff ;
}
}
file.close () ;
}
//**********************************************************
// CLASS NAME : ROOM
// FUNCTION NAME : DISPLAY_ROOM_RECORD
// DETAILS : IT GIVES ROOM NO. TO DISPLAY THE ROOM
// RECORD.
//**********************************************************
void room :: display_room_record(void)
{
clrscr() ;
int valid ;
int t_roomno ;
gotoxy(1,3) ;
cout <<"Enter the Room no. : " ;
cin >>t_roomno ;
if (!room_found(t_roomno))
{
sound(500) ;
delay(100) ;
nosound() ;
gotoxy(1,25) ; clreol() ;
gotoxy(1,24) ;
cout <<"ROOM NO. NOT FOUND" ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
return ;
}
clrscr() ;
gotoxy(5,3) ;
cout <<"ROOM RECORD" ;
display_record(t_roomno) ;
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getch() ;
}
//**********************************************************
// CLASS NAME : ROOM
// FUNCTION NAME : CHANGE_STATUS
// DETAILS : IT CHANGES THE STATUS OF THE GIVEN
// ROOM TO THE GIVEN STATUS.
//**********************************************************
void room :: change_status(int t_roomno , char t_status)
{
int recno ;
recno = recordno(t_roomno) ;
fstream file ;
file.open("ROOM.DAT", ios::out | ios::ate) ;
int location ;
location = (recno-1) * sizeof(room) ;
file.seekp(location) ;
status = t_status ;
file.write((char *) this, sizeof(room)) ;
file.close () ;
}
//**********************************************************
// CLASS NAME : ROOM
// FUNCTION NAME : ROOM_STATUS
// DETAILS : IT RETURNS THE STATUS OF THE GIVEN
// ROOM NO.
//**********************************************************
char room :: room_status(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
int found = 0 ;
char t_status ;
while (file.read((char *) this, sizeof(room)) && !found)
{
if (t_roomno == roomno)
{
found = 1 ;
t_status = status ;
}
}
file.close () ;
return t_status ;
}
//**********************************************************
// CLASS NAME : ROOM
// FUNCTION NAME : GET_DATA
// DETAILS : IT RETURNS THE TARRIFF OF THE GIVEN
// ROOM NO.
//**********************************************************
float room :: get_data(int t_roomno)
{
fstream file ;
file.open("ROOM.DAT", ios::in) ;
file.seekg(0) ;
float t_tarriff ;
while (file.read((char *) this, sizeof(room)))
{
if (t_roomno == roomno)
{
t_tarriff = tarriff ;
break ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -