#include<iostream.h>
#include<string.h>
//***********************************************************************************
void initial_room(); //初始化80个房间信息
void welcome(); //验证用户登陆,登陆成功显示欢迎信息
void enter();
void book_room();
void check_in();
void check_out();
void inquire();
int i=0;
//***********************************************************************************
struct Room
{
int number;
int dank;
int price;
int state;
};
class Customer
{
public:
Customer();
void set_name(char *n){strcpy(name,n);}
void set_ID(char *p){strcpy(ID,p);}
void set_room_number(int n){room_number=n;}
void set_day(int d){day=d;}
void set_prepaid(int p){prepaid=p;}
char *get_name(){return name;}
char *get_ID(){return ID;}
int get_room_number(){return room_number;}
int get_day(){return day;}
int get_prepaid(){return prepaid;}
virtual ~Customer();
private:
char name[10],ID[19];
int room_number;
int prepaid;
int change;
int day;
};
Customer::Customer()
{
cout<<"请您输入顾客的姓名\n";
cin>>name;
cout<<"请您输入顾客的身份证号码\n";
cin>>ID;
prepaid=change=day=0;
}
Customer::~Customer()
{
cout<<"该顾客退房成功!"<<endl;
}
//***********************************************************************************
Room room[80];
Customer *customer[80];
void main() //程序入口从这里开始运行
{
char choice='1';
initial_room(); //初始化80个房间的信息,分四个等级
welcome(); //验证用户登陆,登陆成功显示欢迎信息
while(choice=='1')
{
enter(); //根据用户的选择执行不同的功能
cout<<endl;
cout<<"继续使用本系统请按\"1\",退出请按\"2\"! ";
cin>>choice;
cout<<endl;
}
}
//系统登陆界面***********************************************************************
void welcome() //验证用户登陆,登陆成功显示欢迎信息
{
char name[4],code[7];
cout<<"请输入用户名和密码(以空格隔开):\n";
cin>>name>>code;
while((strcmp(name,"000")!=0)||(strcmp(code,"666666")!=0))
{
cout<<"用户名或密码输入有误,请重新输入!\n";
cin>>name>>code;
}
cout<<endl;
cout<<endl;
cout<<" ▲***************************▲\n";
cout<<" △ 欢迎使用***系统!△\n";
cout<<" ▲***************************▲\n";
cout<<endl;
}
//系统入口***************************************************************************
void enter()
{
int kind_of_service;
cout<<"请选择服务类别:订房、入住、退房还是查询? \n";
cout<<" 1->定房 2->入住 3->退房 4->查询: ";
cin>>kind_of_service;
if((kind_of_service>4) || (kind_of_service<1))
{
cout<<"您的输入有误,请重试!\n";
cin>>kind_of_service;
}
else
switch(kind_of_service)
{
case 1: book_room();
break;
case 2: check_in();
break;
case 3: check_out();
break;
case 4: inquire();
break;
}
}
//订房实现***************************************************************************
void book_room()
{
customer[i]=new Customer;
int room_standard,day;
cout<<"请您选择预定房间的标准:\n";
cout<<"1.单人间/天150元\n2.双人间/天200元\n3.标准间/天300元\n4.总统套房/天600元\n";
cin>>room_standard;
cout<<"请输入预定天数\n";
cin>>day;
customer[i]->set_day(day);
switch(room_standard)
{
int n;
case 1:
cout<<"住房费用总共为: "<<day*150<<"元\n"; //计算住房费用
for(n=0;n<20;n++) //从第一个级别的房间中查找一个空闲的房间
{
if(room[n].state==0) //state=0表示该住房没有被预定的
{
cout<<"预定成功★房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 2:
cout<<"住房费用总共为: "<<day*200<<" 元\n";
for(n=20;n<40;n++)
{
if(room[n].state==0)
{
cout<<"预定成功★房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 3:
cout<<"住房费用总共为: "<<day*300<<" 元\n";
for(n=40;n<60;n++)
{
if(room[n].state==0)
{
cout<<"预定成功★房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 4:
cout<<"住房费用总共为: "<<day*600<<"元\n";
for(n=60;n<80;n++)
{
if(room[n].state==0)
{
cout<<"预定成功★房间号码为: "<<room[n].number<<endl;
room[n].state=1;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
}
i++; //住房的顾客数加1
}
//入住登记***************************************************************************
void check_in()
{
char name1[10],id1[19];
int ding_or_no,prepaid;
cout<<"该顾客订房了吗? (1->订了 2->没订) ";
cin>>ding_or_no;
if(ding_or_no==1)
{
cout<<"请输入顾客的姓名:"<<endl;
cin>>name1;
cout<<"请输入顾客的身份证号码:"<<endl;
cin>>id1;
for(int j=0;j<=i;j++)
{
if((strcmp(customer[j]->get_name(),name1)==0)&&(strcmp(customer[j]->get_ID(),id1)==0)) //查找该顾客的定房信息
{
int num=customer[j]->get_room_number(); //取得定房的房间号
cout<<"顾客"<<name1<<"今天入住本宾馆! 房间号码为: "<<num<<endl;
switch(num/100)
{
case 6:
prepaid=customer[j]->get_day()*150;
customer[j]->set_prepaid(prepaid);
cout<<"请收房费 "<<prepaid<<"元整!"<<endl; //开始收费
room[num%100-1].state=2; //修改房间状态为入住状态
break;
case 7:
prepaid=customer[j]->get_day()*200;
customer[j]->set_prepaid(prepaid);
cout<<"请收房费 "<<prepaid<<"元整!"<<endl;
room[19+num%100].state=2;
break;
case 8:
prepaid=customer[j]->get_day()*300;
customer[j]->set_prepaid(prepaid);
cout<<"请收房费 "<<prepaid<<"元整!"<<endl;
room[39+num%100].state=2;
break;
case 9:
prepaid=customer[j]->get_day()*600;
customer[j]->set_prepaid(prepaid);
cout<<"请收房费 "<<prepaid<<"元整!"<<endl;
room[59+num%100].state=2;
break;
}
break;
}
}
}
else
{
customer[i]=new Customer;
int room_standard,day;
cout<<"请您选择预定房间的标准:\n";
cout<<"1.单人间/天150元\n2.双人间/天200元\n3.标准间/天300元\n4.总统套房/天600元\n";
cin>>room_standard;
cout<<"请输入住宿天数\n";
cin>>day;
customer[i]->set_day(day);
switch(room_standard)
{
int n;
case 1:
prepaid=day*150;
customer[i]->set_prepaid(prepaid);
cout<<"请收房费 "<<prepaid<<"元整!\n";
for(n=0;n<20;n++)
{
if(room[n].state==0)
{
cout<<"入住房间号码为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 2:
prepaid=day*200;
customer[i]->set_prepaid(prepaid);
cout<<"请收房费 "<<prepaid<<"元整!\n";
for(n=20;n<40;n++)
{
if(room[n].state==0)
{
cout<<"入住房间号码为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 3:
prepaid=day*300;
customer[i]->set_prepaid(prepaid);
cout<<"请收房费 "<<prepaid<<"元整!\n";
for(n=40;n<60;n++)
{
if(room[n].state==0)
{
cout<<"入住房间号码为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
case 4:
prepaid=day*600;
customer[i]->set_prepaid(prepaid);
cout<<"请收房费 "<<prepaid<<"元整!\n";
for(n=60;n<80;n++)
{
if(room[n].state==0)
{
cout<<"入住房间号码为: "<<room[n].number<<endl;
room[n].state=2;
customer[i]->set_room_number(room[n].number);
break;
}
}
break;
}
i++;
}
}
//退房结算***************************************************************************
void check_out()
{
char na
老歪不歪
- 粉丝: 44
- 资源: 4368
最新资源
- 基于java+spring+springMVCl的学生就业管理系统开题报告.doc
- 一个C++实现的简易动态语言解释器,可定义变量和函数,有if和while两种控制流语句,词法分析和语法分析分别使用flex和bison实现,参考自《flex & bison》.zip
- 深入理解编程中的回调函数:原理、实现及应用场景
- yolov8l-cls.pt
- 操作系统中银行家算法详解与Python实现防止死锁
- 使用Java实现回调函数代码示例callback.zip
- Vue+ElementPlus构建的CMS开发框架.rar
- yolov8图像分类模型yolov8m-cls.pt
- yolov8图像分类yolov8s-cls.pt模型
- 使用Java实现字符串左移指定位数StringRotation.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈