class hotel
{
//========================== customer variable declarations ==============
int room_no;
char name[30];
char address[30];
char phone[10];
int date;
int getDate() { return date;}
int z;
char type[25];
//========================== staff menu ============================
public:
void main_menu(); //to display main menu
void staff_menu(); //to display staff menu
void cust_menu(); //to display customer menu
//================== staff role ====================================
void display_rec(); //to display customer record
void edit(); //edit customer record
void modify(int); //to modify record
void delete_rec(int); //to delete cust record
void availability(); //to check room available or not
//============================= cust role ====================
void room_info(); //to display room type, price, facilities, number
void book_room(); //to book a room
int check(int);
void BubbleSort();
void getData();
void print( );
};
//============================= prompt user to select role =====================
void hotel::main_menu()
{
switch(apps)
{
case 1: staff_menu();
break;
case 2: cust_menu();
break;
default: cout<<"\n Wrong Choice.....!!";
}
cout<<"\n Press any key to continue....!!!";
getch();
}
void hotel::staff_menu()
{ clrscr();
int choice;
while(choice!=4)
{
cout<<"\n\t\t\t\t*************************";
cout<<"\n\t\t\t\t* STAFF MENU *";
cout<<"\n\t\t\t\t*************************";
cout<<"\n\n\t\t\t\t1.Display Customer Record";
cout<<"\n\n\t\t\t\t2.Check Availabilty";
cout<<"\n\n\t\t\t\t3.Edit Customer Record";
cout<<"\n\n\t\t\t\t4.Exit";
cout<<"\n\n\n\t\t\t\tEnter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1: display_rec();
break;
case 2: availability();
break;
case 3: edit();
break;
case 4: break;
default:
{
cout<<"\n\n\t\t\tWrong choice.....!!!";
cout<<"\n\t\t\tPress any key to continue....!!";
}
}
}
}
//===================================================================
void hotel::book_room()
{
clrscr();
int r,flag;
ofstream fout("Record.dat",ios::app); //ofstream:Stream class to write on files
cout<<"\n Enter your choice: ";
cin>>choice;
clrscr();
cout<<"\n Enter room no: " ;
cin>>r;
switch(choice)
{
case 1: modify(r);
break;
case 2: delete_rec(r);
break;
default: cout<<"\n Record Not Found.....!!";
}
cout<<"\n Press any key to continue....!!!";
getch();
}
//=================================modify 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));
if(room_no==r)
{
cout<<"\n Enter New Details";
cout<<"\n -----------------";
fin.close();
fout.close();
if(flag==0)
cout<<"\n Sorry room no. not found or vacant...!!";
else
{
remove("Record.dat");
rename("temp.dat","Record.dat");
}
}
//=========================== Customer Menu ===================================
void hotel::cust_menu()
{
clrscr();
int cust;
while(cust!=4)
{
cout<<"\n\t\t\t\t****************************";
cout<<"\n\t\t\t\t* CUSTOMER MENU *";
cout<<"\n\t\t\t\t****************************";
cout<<"\n\n\n\n\t\t\t\t1.Display Room Info";
cout<<"\n\n\t\t\t\t2.Check Availabilty";
cout<<"\n\n\t\t\t\t3.Book A Room";
cout<<"\n\n\t\t\t\t4.Exit";
cout<<"\n\n\n\n\t\t\t\tEnter Your Choice: ";
cin>>cust;
switch(cust)
{
case 1: room_info();
break;
case 2: availability();
break;
case 3: book_room();
break;
case 4: break;
default:
{
cout<<"\n\n\t\t\tWrong choice.....!!!";
cout<<"\n\t\t\tPress any key to continue....!!";
}
}
}
}
//=============================== room info =================
void hotel::room_info(){}
//==================view Room Alloted(sorted view)====================================
void hotel::BubbleSort(hotel data[],int listSize)
{
int x ;
hotel tempValue;
for ( int pass =1;pass < listSize; pass++ )
if (data[x].getDate()> data[x+1].getDate()) // swap if the data is not in the right order
{
tempValue = data[x];
data[x] = data[x+1];
data[x+1] = tempValue;
}
}
//==================== main ================================
main()
{
hotel h;
cout<<"\n\t\t\t****************************";
cout<<"\n\t\t\t* HOTEL BOOKING SYSTEM *";
cout<<"\n\t\t\t****************************";
hotel myHotel[size];
for (int j=0; j<size; j++)
{
myHotel[j].getData();
}
for (int j=0; j<size; j++)
{
myHotel[j].print();
}
BubbleSort(myHotel,size) ; // sort the array using bubble sort
cout << "\nThe list after sort based on the date -> \n";