没有合适的资源?快使用搜索试试~ 我知道了~
C++版酒店管理程序代码.doc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 145 浏览量
2021-10-11
16:30:08
上传
评论
收藏 57KB DOC 举报
温馨提示
试读
15页
C++版酒店管理程序代码.doc
资源推荐
资源详情
资源评论
- .
程序代码
N:最终改良版代码〔利用构造体储存多种类型的数据〕
好处:比数组能储存更多类型的数据!
#include<iostream>
#include<string>
#include<cstdlib> //常用函数库
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 ame; //顾客 XX
int stayTime; //预定天数
int roomType; //房间类型〔1.标准单人间 2.大床房 3.标准双人间 4. 套房〕
string phoneNum; // 预留手机号
public:
void setData()
{
- . 可修编.
- .
string name;
int time;
int type;
string num;
cout<<" 您 好 , 请 输 入 您 的 XX : "<<endl;cin>>name;
ame=name;
cout<<"预定天数为:"<<endl; cin>>time; stayTime=time;
cout<<"想要预定的房间类型:1.标准单人间 100/天 2.大床房 200/
天 3. 标 准 双 人 间 300/ 天 4. 套 房 400/ 天 "<<endl;cin>>type;
roomType=type;
cout<<"预留手机号:"<<endl;cin>>num; phoneNum=num;
};
void Book()
{
cout<<"正在预定..."<<endl;
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->ame;
room[i].Phone=this->phoneNum;
room[i].Price*=this->stayTime;
cout<<" 预 定 成 功 ! 房 间 号 :
"<<room[i].Number<<endl<<endl;
room[i].State=1;break; //已被预订
}
else cout<<room[i].Number<<"号房间已有人"<<endl;
}break;
case 2:for(int i=20;i<40;i++)
{
if(room[i].State==0)
{
room[i].days=this->stayTime;
room[i].Name=this->ame;
room[i].Phone=this->phoneNum;
room[i].Price*=this->stayTime;
cout<<" 预 定 成 功 ! 房 间 号 :
"<<room[i].Number<<endl<<endl;
room[i].State=1; break;
}
- . 可修编.
- .
else cout<<room[i].Number<<"号房间已有人"<<endl;
}break;
case 3:for(int i=40;i<60;i++)
{
if(room[i].State==0)
{
room[i].days=this->stayTime;
room[i].Name=this->ame;
room[i].Phone=this->phoneNum;
room[i].Price*=this->stayTime;
cout<<" 预 定 成 功 ! 房 间 号 :
"<<room[i].Number<<endl<<endl;
room[i].State=1; break;
}
else cout<<room[i].Number<<"号房间已有人"<<endl;
}break;
case 4:for(int i=60;i<80;i++)
{
if(room[i].State==0)
{
room[i].days=this->stayTime;
room[i].Name=this->ame;
room[i].Phone=this->phoneNum;
room[i].Price*=this->stayTime;
cout<<" 预 定 成 功 ! 房 间 号 :
"<<room[i].Number<<endl<<endl;
room[i].State=1; break;
}
else cout<<room[i].Number<<" 号 房 间 已 有
人"<<endl;
}break;
default:cout<<"您输入的房间类型有误!"<<endl;
}
};
};
class CheckIn //定义办理入住类
{
private:
string ame;
string cSex;
string idNum; //XX 号
- . 可修编.
剩余14页未读,继续阅读
资源评论
wsbhm62
- 粉丝: 7
- 资源: 22万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功