C版酒店管理程序代码.docx
- 文档编号:230149
- 上传时间:2022-10-07
- 格式:DOCX
- 页数:25
- 大小:20.96KB
C版酒店管理程序代码.docx
《C版酒店管理程序代码.docx》由会员分享,可在线阅读,更多相关《C版酒店管理程序代码.docx(25页珍藏版)》请在冰豆网上搜索。
程序代码
N:
最终改进版代码(利用结构体储存多种类型的数据)
好处:
比数组能储存更多类型的数据!
#include
#include
#include
usingnamespacestd;
/*在c++中struct和类的区别在于struct不能有方法,所有成员是public的*/
structRoom
{
intNumber;
intPrice;
intState;
intdays;
stringName;
stringPhone;
stringID;
};//room;可以在声明struct的时候声明一个struct实例
Roomroom[80];
classBookRoom//定义预定房间类
{
private:
stringcName;//顾客姓名
intstayTime;//预定天数
introomType;//房间类型(1.标准单人间2.大床房3.标准双人间4.套房)
stringphoneNum;//预留手机号
public:
voidsetData()
{
stringname;
inttime;
inttype;
stringnum;
cout<<"您好,请输入您的姓名:
"<
cout<<"预定天数为:
"<
cout<<"想要预定的房间类型:
1.标准单人间100/天2.大床房200/天3.标准双人间300/天4.套房400/天"<
cout<<"预留手机号:
"<
};
voidBook()
{
cout<<"正在预定..."< switch(this->roomType) { case1: for(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<<"预定成功! 房间号: "< room[i].State=1;break;//已被预订 } elsecout< }break; case2: for(inti=20;i<40;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<<"预定成功! 房间号: "< room[i].State=1;break; } elsecout< }break; case3: for(inti=40;i<60;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<<"预定成功! 房间号: "< room[i].State=1;break; } elsecout< }break; case4: for(inti=60;i<80;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<<"预定成功! 房间号: "< room[i].State=1;break; } elsecout< }break; default: cout<<"您输入的房间类型有误! "< } }; }; classCheckIn//定义办理入住类 { private: stringcName; stringcSex; stringidNum;//身份证号 intcheck_inDate;//入住日期 intstayTime; introomType; stringphoneNum; public: voidunbooked() { stringname; stringsex; stringidnum; intdate; inttime; inttype; stringnum; cout<<"客户姓名: "< cout<<"客户性别: "< cout<<"客户身份证号: "< cout<<"入住日期: "< cout<<"占用天数: "< cout<<"房间类型: 1.标准单人间100/天2.大床房200/天3.标准双人间300/天4.套房400/天"< cout<<"客户手机号: "< switch(this->roomType) { case1: for(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; room[i].ID=this->idNum; cout<<"入住成功! 房间号: "< cout<<"请支付200元押金"< room[i].State=1; break; } elsecout<<"抱歉,该房间类型没有了"< }break; case2: for(inti=20;i<40;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; room[i].ID=this->idNum; cout<<"入住成功! 房间号: "< cout<<"请支付400元押金"< room[i].State=1; break; } elsecout<<"抱歉,该房间类型没有了"< }break; case3: for(inti=40;i<60;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; room[i].ID=this->idNum; cout<<"入住成功! 房间号: "< cout<<"请支付600元押金"< room[i].State=1; break; } elsecout<<"抱歉,该房间类型没有了"< }break; case4: for(inti=60;i<80;i++) { if(room[i].State==0){ room[i].days=this->stayTime; room[i].Name=this->cName; room[i].Phone=this->phoneNum; roo
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 酒店 管理 程序代码