C版酒店管理程序代码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

C版酒店管理程序代码 Document serial number【NL89WT-NY98YT-NC8CB-NNUUT-NUT108】

程序代码

N:最终改进版代码(利用结构体储存多种类型的数据)

好处:比数组能储存更多类型的数据!

#include

#include

#include //常用函数库

using namespace std;

/*在c++中struct和类的区别在于struct不能有方法,所有成员是public的*/ struct Room

{

int Number;

int Price;

int State;

int days;

string Name;

string Phone;

string ID;

};//room; 可以在声明struct的时候声明一个struct实例

Room room[80];

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<<"正在预定..."<

switch(this->roomType)

{

case 1:for(int i=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; //已被预订

}

else cout<

}break;

case 2:for(int i=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;

}

else cout<

}break;

case 3:for(int i=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;

}

else cout<

}break;

case 4:for(int i=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;

}

else cout<

}break;

default:cout<<"您输入的房间类型有误!"<

}

};

};

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;

相关文档
最新文档