欢迎来到天天文库
浏览记录
ID:40547484
大小:24.93 KB
页数:25页
时间:2019-08-04
《C++版酒店管理程序代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、程序代码N:最终改进版代码(利用结构体储存多种类型的数据)好处:比数组能储存更多类型的数据!#include#include#include//常用函数库usingnamespacestd;/*在c++中struct和类的区别在于struct不能有方法,所有成员是public的*/structRoom{intNumber;intPrice;intState;intdays;stringName;stringPhone;stringID;};//room;可以在
2、声明struct的时候声明一个struct实例Roomroom[80];classBookRoom//定义预定房间类{private:stringcName;//顾客姓名intstayTime;//预定天数introomType;//房间类型(1.标准单人间2.大床房3.标准双人间4.套房)stringphoneNum;//预留手机号public:voidsetData(){stringname;inttime;inttype;stringnum;cout<<"您好,请输入您的姓名:"<>na
3、me;cName=name;cout<<"预定天数为:"<>time;stayTime=time;cout<<"想要预定的房间类型:1.标准单人间100/天2.大床房200/天3.标准双人间300/天4.套房400/天"<>type;roomType=type;cout<<"预留手机号:"<>num;phoneNum=num;};voidBook(){cout<<"正在预定..."<roomType){case1:f
4、or(inti=0;i<20;i++){if(room[i].State==0)//房间无人占用且无人预定{room[i].days=this->stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<5、Number<<"号房间已有人"<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<6、}elsecout<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<7、m[i].State=1;break;}elsecout<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<8、ber<
5、Number<<"号房间已有人"<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<6、}elsecout<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<7、m[i].State=1;break;}elsecout<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<8、ber<
6、}elsecout<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<7、m[i].State=1;break;}elsecout<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<8、ber<
7、m[i].State=1;break;}elsecout<stayTime;room[i].Name=this->cName;room[i].Phone=this->phoneNum;room[i].Price*=this->stayTime;cout<<"预定成功!房间号:"<8、ber<
8、ber<
此文档下载收益归作者所有