资源预览内容
第1页 / 共25页
第2页 / 共25页
第3页 / 共25页
第4页 / 共25页
第5页 / 共25页
第6页 / 共25页
第7页 / 共25页
第8页 / 共25页
第9页 / 共25页
第10页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
程序代码N:最终改进版代码(利用结构体储存多种类型的数据)好处:比数组能储存更多类型的数据!#include#include#include /常用函数库 using namespace std;/*在c+中struct和类的区别在于struct不能有方法,所有成员是public的*/struct Roomint Number;int Price;int State;int days;string Name;string Phone;string ID;/room; 可以在声明struct的时候声明一个struct实例Room room80;class BookRoom /定义预定房间类 private:string cName; /顾客姓名int stayTime; /预定天数int roomType; /房间类型(1.标准单人间 2.大床房 3.标准双人间 4. 套房)string phoneNum; / 预留手机号public: void setData() string name; int time; int type; string num; cout您好,请输入您的姓名:name; cName=name;cout预定天数为:time; stayTime=time;cout想要预定的房间类型:1.标准单人间 100/天 2.大床房 200/天 3.标准双人间 300/天 4.套房400/天type; roomType=type;cout预留手机号:num; phoneNum=num;void Book()cout正在预定.roomType)case 1:for(int i=0;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;cout预定成功!房间号:roomi.Numberendlendl;roomi.State=1;break; /已被预订 else coutroomi.Number号房间已有人endl;break;case 2:for(int i=20;istayTime; roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime; cout预定成功!房间号:roomi.Numberendlendl;roomi.State=1; break; else coutroomi.Number号房间已有人endl;break;case 3:for(int i=40;istayTime; roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime; cout预定成功!房间号:roomi.Numberendlendl;roomi.State=1; break; else coutroomi.Number号房间已有人endl;break;case 4:for(int i=60;istayTime; roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime; cout预定成功!房间号:roomi.Numberendlendl;roomi.State=1; break;else coutroomi.Number号房间已有人endl;break;default:cout您输入的房间类型有误!endl; ;class CheckIn /定义办理入住类private:string cName;string cSex;string idNum; /身份证号 int check_inDate; /入住日期 int stayTime; int roomType; string phoneNum;public:void unbooked()string name;string sex;string idnum;int date;int time;int type;string num;cout客户姓名:name; cName=name;cout客户性别:sex; cSex=sex; cout客户身份证号:idnum; idNum=idnum;cout入住日期:date; check_inDate=date;cout占用天数:time;stayTime=time;cout房间类型:1.标准单人间 100/天 2.大床房 200/天 3.标准双人间 300/天 4.套房 400/天type;roomType=type;cout客户手机号:num; phoneNum=num;switch(this-roomType)case 1:for(int i=0;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;roomi.ID=this-idNum;cout入住成功!房间号:roomi.Numberendlendl;cout请支付200元押金endlendl;roomi.State=1;break; else cout抱歉,该房间类型没有了endl;break;case 2:for(int i=20;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;roomi.ID=this-idNum;cout入住成功!房间号:roomi.Numberendlendl;cout请支付400元押金endlendl;roomi.State=1;break; else cout抱歉,该房间类型没有了endl;break;case 3:for(int i=40;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;roomi.ID=this-idNum;cout入住成功!房间号:roomi.Numberendlendl;cout请支付600元押金endlendl;roomi.State=1;break; else cout抱歉,该房间类型没有了endl;break;case 4:for(int i=60;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roo
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号