#include <iostream.h>
#include <string.h>
#include <fstream.h>
char fileName[]="hotel.dat";
class Date
{
int Month,Day,Year;
public:
Date()
{ Month=0;
Day=0;
Year=0;
}
void clear()
{
Month=0;
Day=0;
Year=0;
}
void set_year()
{
cout<<"年:";
cin>>Year;
}
void set_month()
{ cout<<"月:";
cin>>Month;
}
void set_day()
{
cout<<"日:";
cin>>Day;
}
void show()
{
cout<<"入住日期:"<<Year<<"-"<<Month<<"-"<<Day<<endl;;
}
};
class Room
{
protected:
Date get_time;
int num;
char name[10];
char ID[18];
char name1[10];
char ID1[18];
public:
int room_number;
Room()
{
room_number=0;
strcpy(name,"empty");
strcpy(ID,"empty");
strcpy(name1,"empty");
strcpy(ID1,"empty");
}
void set_num()
{
num=0;
}
int Get_num()
{
return num;
}
int Get_room_number()
{
return room_number;
}
char *get_ID()
{
return ID;
}
char *get_ID1()
{
return ID1;
}
void input();
void revise();
void input1();
void tuifang();
void output();
};
void Room::tuifang()
{
room_number=0;
strcpy(name,"empty");
strcpy(ID,"empty");
strcpy(name1,"empty");
strcpy(ID1,"empty");
get_time.clear();
}
void Room::input()
{
cout<<"房间号(请在查看后确定该房间无人并且酒店有该房间号再输入):";
cin>>room_number;
cout<<"客户姓名:";
cin>>name;
cout<<"身份证号:";
cin>>ID;
cout<<"入住时间:";
get_time.set_year();
get_time.set_month();
get_time.set_day();
}
void Room::revise()
{
strcpy(name,"empty");
strcpy(ID,"empty");
strcpy(name1,"empty");
strcpy(ID1,"empty");
Room::input();
}
void Room::input1()
{
cout<<"房间号(请在查看后确定该房间无人并且酒店有该房间号再输入):";
cin>>room_number;
cout<<"客户姓名:";
cin>>name;
cout<<"身份证号:";
cin>>ID;
cout<<"客户姓名:";
cin>>name1;
cout<<"身份证号:";
cin>>ID1;
cout<<"入住时间:";
get_time.set_year();
get_time.set_month();
get_time.set_day();
}
void Room::output()
{
cout<<"房间号:";
cout<<room_number<<endl;
cout<<"客户姓名:";
cout<<name<<endl;
cout<<"身份证号:";
cout<<ID<<endl;
cout<<"客户姓名:";
cout<<name1<<endl;
cout<<"身份证号:";
cout<<ID1<<endl;
get_time.show();
}
class Pubiao:public Room
{
public:
Pubiao()
{}
void set_num()
{
num=1;
}
void input();
void input1();
};
class Shangbiao:public Room
{
public:
Shangbiao()
{}
void set_num()
{
num=2;
}
void input();
void input1();
};
class Puda:public Room
{
public:
Puda()
{}
void set_num()
{
num=3;
}
void input();
void input1();
};
class Haoda:public Room
{
public:
Haoda()
{}
void set_num()
{
num=4;
}
void input();
void input1();
};
class Xingtao:public Room
{
public:
Xingtao()
{}
void set_num()
{
num=5;
}
void input();
void input1();
};
class Haotao:public Room
{
public:
Haotao()
{}
void set_num()
{
num=6;
}
void input();
void input1();
};
void Pubiao::input()
{
cout<<"普通标间房间号(101-110)"<<endl;
Room::input();
}
void Pubiao::input1()
{
cout<<"普通标间房间号(101-110)"<<endl;
Room::input1();
}
void Shangbiao::input()
{
cout<<"商务标间房间号(201-210)"<<endl;
Room::input();
}
void Shangbiao::input1()
{
cout<<"商务标间房间号(201-210)"<<endl;
Room::input1();
}
void Puda::input()
{
cout<<"普通大床房房间号(301-310)"<<endl;
Room::input();
}
void Puda::input1()
{
cout<<"普通大床房房间号(301-310)"<<endl;
Room::input1();
}
void Haoda::input()
{
cout<<"豪华大床房房间号(401-410)"<<endl;
Room::input();
}
void Haoda::input1()
{
cout<<"豪华大床房房间号(401-410)"<<endl;
Room::input1();
}
void Xingtao::input()
{
cout<<"行政套房房间号(501-505)"<<endl;
Room::input();
}
void Xingtao::input1()
{
cout<<"行政套房房间号(501-505)"<<endl;
Room::input1();
}
void Haotao::input()
{
cout<<"豪华套房房间号(506-510)"<<endl;
Room::input();
}
void Haotao::input1()
{
cout<<"豪华套房房间号(506-510)"<<endl;
Room::input1();
}
class System
{
Room A;
Pubiao B[10];
Shangbiao C[10];
Puda D[10];
Haoda E[10];
Xingtao F[5];
Haotao G[5];
static int j1,j2,j3,j4,j5,j6;
void infor1();
void infor2();
void infor3();
void infor4();
void infor5();
void infor6();
void save();
void Menu1();
void Menu2();
public:
System(){ save();};
void Menu();
void In_information();
void Check();
void Leave();
void Revise();
};
void System::Menu1()
{
cout<<"******************房间类型*****************"<<endl;
cout<<" 1.普通标间 "<<endl;
cout<<" 2.商务标间 "<<endl;
cout<<" 3.普通大床房 "<<endl;
cout<<" 4.豪华大床房 "<<endl;
cout<<" 5.行政套房 "<<endl;
cout<<" 6.豪华套房 "<<endl;
cout<<" 7.退出 "<<endl;
cout<<" 请选择房间类型 "<<endl;
}
void System::Menu2()
{
cout<<"******************查询客房系统*******************"<<endl;
cout<<" 1.查询所有客房信息 "<<endl;
cout<<" 2.查询具体客房信息 "<<endl;
cout<<" 3.查询顾客 "<<endl;
cout<<" 4.退出 "<<endl;
cout<<" 请选择要进入的操作 "<<endl;
}
void System::In_information()
{
int i,m=0;
char rev1;
int again=1;
char t;
while(again)
{
Menu1();
cin>>rev1;
switch(rev1)
{
case '1':
cout<<"该房型已有人的房间号"<<endl;
for(i=0;i<10;i++)
if(B[i].room_number!=0) cout<<B[i].room_number<<endl;
infor1();
cout<<"\t\t\t 信息储存成功!"<<endl;
cout<<"\t\t\t 是否继续存储(y/n)?"<<endl;
cin>>t;
cout<<endl;
if(!(t=='Y'||t=='y'))
{again=0;Menu();}
break;
case '2':
cout<<"该房型已有人的房间号"<<endl;
for(i=0;i<10;i++)
if(C[i].room_number!=0) cout<<C[i].room_number<<endl;
infor2();
cout<<"\t\t\t 信息储存成功!"<<endl;
cout<<"\t\t\t 是否继续存储(y/n)?"<<endl;
cin>>t;
cout<<endl;
if(!(t=='Y'||t=='y'))
{again=0;Menu();}
break;
case '3':
cout<<"该房型已有人的房间号"<<endl;
for(i=0;i<10;i++)
if(D[i].room_number!=0) cout<<D[i].room_number<<endl;
infor3();
cout<<"\t\t\t 信息储存成功!"<<endl;
cout<<"\t\t\t 是否继续存储(y/n)?"<<endl;
cin>>t;
cout<<endl;
if(!(t=='Y'||t=='y'))
{again=0;Menu();}break;
case '4':
cout<<"该房型已有人的房间号"<<endl;
for(i=0;i<10;i++)
if(E[i].room_number!=0) cout<<E[i].room_number<<endl;
infor4();
cout<<"\t\t\t 信息储存成功!"<<endl;
cout<<"\t\t\t 是否继续存储(y/n)?"<<endl;
cin>>t;
cout<<endl;
if(!(t=='Y'||t=='y'))
{again=0;Menu();}break;
case '5':
cout<<"该房型已有人的房间号"<<endl;
for(i=0;i<5;i++)
if(F[i].room_number!=0) cout<<F[i].room_number<<endl;
infor5();
cout<<"\t\t\t 信息储存成功!"<<endl;
cout<<"\t\t\t 是否继续存储(y/n)?"<<endl;
cin>>t;
cout<<endl;
if(!(t=='Y'||t=='y'))
{again=0;Menu();}break;
case '6':
cout<<"该房型已有人的房间号"<<endl;
for(i=0;i<5;i++)
if(G[i].room_number!=0) cout<<G[i].room_number<<endl;
infor6();
cout<<"\t\t\t 信息储存成功!"<<endl;
cout<<"\t\t\t 是否继续存储(y/n)?"<<endl;
cin>>t;
cout<<endl;
if(!(t=='Y'||t=='y'))
{again=0;Menu();}break;
case '7':
Menu();again=0;break;
default:
cout<<" 没有此类房间! 请重新输入要记录的房间类型 "