


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include <windows.h>#include <dos.h>#include<stdio.h>#include<stdlib.h>#include<time.h>/结构定typedef struct CheckinInformation char name10;/int id;/int roomType;/int countType;/CheckinInfo;姓名证件号房型计费方式typedef struct HotelRoomint roomType;/int roomNum;/int checked;/int pric
2、e;/Room;房型入住情况房价/ 已入住房数/ 单人房剩余房数/ 双人房剩余房数/ 大床房剩余房数枚举类型 typedef struct RoomOrderCheckinInfo *checkinInfo; long date;Room * room;Order;typedef struct HotelInfomation int checkinAmount;int singleRemainAmount;int doubleRemainAmount; int bigRemainAmount;HotelInfo;/ 入住信息/ 入住时间/ 房间信息enum MainUI,HotelInfoUI
3、,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit;/GUI enum Single,Double,Big;/Room Typeenum Hour,Day;/countType/ 全局变量 int GUI = MainUI;Order* orderList100;/ 订单数组Room* roomList100;/ 房间数组HotelInfo * hotelInfo = NULL;/酒店房间信息/ 函数声明 void initiallizeRoomList();void insertToOrderList(Order * order);Room*
4、 getRoomByType(int roomType); Order* getOrderByRoomNum(int roomNum); void showMainUI();void showHotelInfoUI();void showCheckinUI();void showCheckinResultUI();void showOrderUI();void showCheckOutUI();/Main 函数 void main() / 主函数 / 初始化酒店房间信息hotelInfo = (HotelInfo *)malloc(sizeof(HotelInfo); hotelInfo -&
5、gt; singleRemainAmount = 20; hotelInfo -> doubleRemainAmount=40;hotelInfo -> bigRemainAmount=40;hotelInfo -> checkinAmount=0;/ 初始化房间列表 initiallizeRoomList();/ 界面显示while(GUI != Exit)switch(GUI)case MainUI: showMainUI(); break;case HotelInfoUI: showHotelInfoUI(); break;case CheckinUI: showChe
6、ckinUI(); break;case CheckinResultUI: showCheckinResultUI(); break;case OrderUI: showOrderUI(); break;case CheckOutUI: showCheckOutUI(); break;default:break;/ 函数定义 void initiallizeRoomList()/ 房间数组初始化, 初始化的结果是让 roomList 的数组有 100 个 room 指针,而且设置了相应 的值int i;Room*newRoom=NULL;for(i=0;i<20;i+) / 单人房房间信
7、息初始化newRoom = ( Room* )malloc(sizeof(Room);roomListi = newRoom;roomListi->checked=0; roomListi->price=110;roomListi->roomNum=i+1;roomListi->roomType=Single;for(i=20;i<60;i+) / 双人房房间信息初始化newRoom = ( Room* )malloc(sizeof(Room);roomListi = newRoom;roomListi->checked=0;roomListi->pr
8、ice=180;roomListi->roomNum=i+1;roomListi->roomType=Double;for(i=60;i<100;i+) / 大床房房间信息初始化newRoom = ( Room* )malloc(sizeof(Room);roomListi = newRoom;roomListi->checked=0;roomListi->price=180;roomListi->roomNum=i+1;roomListi->roomType=Big;/ 通过所选择的房型获取空房间, 获取房间后将房间信息改为已入住, 并减少相应房型的
9、剩余房间 数Room* getRoomByType(int roomType)int i;switch(roomType)case Single:for(i=0;i<20;i+)if( roomListi->checked = 0)roomListi->checked=1; hotelInfo->singleRemainAmount - ; hotelInfo->checkinAmount+; return roomListi;break;case Double:for(i=20;i<60;i+)if( roomListi->checked = 0)r
10、oomListi->checked=1; hotelInfo->doubleRemainAmount - ; hotelInfo->checkinAmount+; return roomListi;break;case Big:for(i=60;i<100;i+)if( roomListi->checked = 0)roomListi->checked=1; hotelInfo->bigRemainAmount -; hotelInfo->checkinAmount+; return roomListi;break;/ 将订单放入订单列表void
11、 insertToOrderList(Order * order)int i;for( i = 0;i<100;i+)if( orderListi =NULL )orderListi = order; break;/ 通过房号查询订单Order* getOrderByRoomNum(int roomNum)int i;for(i=0;i<100;i+)if( orderListi->room->roomNum = roomNum) return orderListi;void showMainUI()/ 显示主界面,并接受输入int chooseNum;system(&
12、quot;cls");printf("nn= 酒 店 房 间 登 记 与 计 费 管 理 管 理 系 统 =tnnn");printf("*tttt1.入住登记 tttt*n");printf("*tttt2.查询入住情况 ttt*n");printf("*tttt3.查询当前费用 ttt*n");printf("*tttt4.结账退房 tttt*n");printf("*tttt5.退出程序 tttt*nnn");printf("nn= 酒 店 房 间
13、登 记 与 计 费 管 理 管 理 系 统=tnnn"); printf(" 请输入相应编号进入菜单 t"); / 接受输入 scanf("%d",&chooseNum); switch(chooseNum)case 1:GUI = HotelInfoUI;break;case 2:GUI = HotelInfoUI;break;case 3:GUI = OrderUI;break;case 4:GUI = OrderUI; break;case 5: Sleep(3000); GUI = Exit; break;default: br
14、eak;void showHotelInfoUI()int chooseNum;system("cls");printf("nn= 酒 店 入 住 情 况 查 询 菜 单 =tnnnn");printf("*ttt入住房间数 : %dtttt*n", hotelInfo->checkinAmount);printf("*ttt剩余房间数 : t");printf(" 单人房: %dtt*n",hotelInfo->singleRemainAmount);printf("*t
15、tttt双人房: %dtt*n",hotelInfo->doubleRemainAmount);printf("*ttttt大床房: %dtt*nn",hotelInfo->bigRemainAmount);printf("nn= 酒 店 入 住 情 况 查 询 菜 单 =tnnn");printf(" 按 0 :返回 n"); printf(" 按 1 : 登记入住 n");scanf("%d",&chooseNum);switch(chooseNum)case
16、0:GUI = MainUI; break;case 1:GUI = CheckinUI; break;default:GUI = HotelInfoUI; break;void showCheckinUI()Order * newOrder;Room* newRoom = NULL;/ 填写一个新的入住信息CheckinInfo * newCheckinInfo = NULL; int roomTypeNum;int countTypeNum;time_t timep;system("cls");printf("nn= 酒 店 入 住 登 记 菜 单 =tnnn
17、");newCheckinInfo = ( CheckinInfo * )malloc(sizeof(CheckinInfo);printf("*tt 请输入姓名 :");scanf("%s", &(newCheckinInfo->name) );printf("*tt请输入证件号 :");scanf("%d", &(newCheckinInfo->id) );printf("*tt请选择入住房型 :n");printf("ttt1.单人房 ntt
18、t2. 双人房 nttt3. 大床房 n");scanf("%d",&(roomTypeNum);switch(roomTypeNum)/通过输入的数字对应房型case 1:newCheckinInfo->roomType = Single;break;case 2:newCheckinInfo->roomType = Double;break;case 3:newCheckinInfo->roomType = Big;break;default:newCheckinInfo->roomType = Single;break;pri
19、ntf("*tt 请选择计费方式 :n");printf("ttt1.按小时计费 ; nttt2. 按天数计费 n");/通过输入的数字对应计费方式scanf("%d",&countTypeNum);switch(countTypeNum)case 1:newCheckinInfo->countType = Hour;break;case 2:newCheckinInfo->countType = Day;break;printf("nn= 酒 店 入 住 登 记 菜 单 =tnnn");/ 生
20、成一个新的订单newOrder = ( Order* )malloc(sizeof(Order);newOrder -> checkinInfo = newCheckinInfo;newOrder -> date = time(0); switch(newCheckinInfo->roomType) case Single:newRoom = getRoomByType(Single); break; case Double:newRoom=getRoomByType(Double); break; case Big :newRoom=getRoomByType(Big);
21、break; newOrder->room = newRoom; insertToOrderList(newOrder);printf(" 房间号为 :%dn",newOrder->room->roomNum); GUI = CheckinResultUI;void showCheckinResultUI()int chooseNum; printf("nn/酒店通过房型获取房间住登记确认菜单=tnnn"); printf("ttt*ttttn"); printf("ttt* 登记成功 *ttttn&quo
22、t;); printf("ttt*ttttnn"); printf("nn=酒店住登记确认菜单=tnnn");printf(" 按 0 :返回 n");scanf("%d",&chooseNum);switch(chooseNum)case 0:GUI = MainUI; break;default:GUI = CheckinResultUI; break;void showOrderUI()int roomNum;int chooseNum;int amount;Order * theOrder = NU
23、LL;system("cls");菜单printf("nn= 酒 店 房 间 信 息 查 询 =tnnn");printf(" 请输入房间号 :");scanf("%d",&roomNum);if (roomNum<0 | roomNum>100)printf("n 输入有误请重新输入 ") ;GUI = OrderUI;elsetheOrder = getOrderByRoomNum(roomNum);printf(" 房型: ");switch(the
24、Order->room->roomType)case Single:printf(" 单人房 n");break;case Double:printf(" 双人房 n");break;case Big:printf(" 大床房 n");break;printf(" 计费方式: "); switch(theOrder->checkinInfo->countType ) case Hour:printf(" 小时计费 n");amount = (time(0) - theOrder->date) / 3600 +1;prin tf("已入住时间:d 小时 n",amou nt);break;case Day:printf(" 天计费 n");amoun
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中国过滤嘴材料行业投资分析及发展战略研究咨询报告
- 可研究性报告范例6
- 烽火轮双轴承单轮行业行业发展趋势及投资战略研究分析报告
- 2025年逆流式冷却塔项目可行性研究报告
- 2025年中国重卡整体行业市场深度研究及投资规划建议报告
- 中国碳纤维轮毂行业市场发展监测及投资潜力预测报告
- 妇幼卫生工作第三季度督导整改情况的报告(三)
- 2025-2031年中国纸浆生产机械行业发展监测及投资战略咨询报告
- 2024-2025年中国票务代理行业市场深度分析及发展前景预测报告
- 2025年烧烤鱿鱼板项目投资可行性研究分析报告
- 幕墙工安全技术交底
- 集装箱七点检查表
- 7S管理标准目视化管理标准
- 篮球场改造工程投标方案(技术方案)
- 茉莉花的生长习性及栽培管理办法
- 蛤蟆先生去看心理医生
- 悬挑式卸料平台安拆作业安全技术交底
- 疾病诊断编码库ICD-10
- 脑血管造影病人的护理-课件
- 阿里巴巴管理精髓管理者必修的24招
- 西汉-北京大学历史学系教学课件
评论
0/150
提交评论