




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include <windows.h>#include <dos.h>#include<stdio.h>#include<stdlib.h>#include<time.h>/-结构定义-typedef struct CheckinInformationchar name10; /姓名int id; /证件号int roomType; /房型int countType; /计费方式CheckinInfo;typedef struct HotelRoomint roomType; /房型int roomNum; /房号int check
2、ed; /入住情况int price; /房价Room;typedef struct RoomOrderCheckinInfo *checkinInfo; /入住信息long date; /入住时间Room * room; /房间信息Order;typedef struct HotelInfomationint checkinAmount; /已入住房数int singleRemainAmount; /单人房剩余房数int doubleRemainAmount; /双人房剩余房数int bigRemainAmount; /大床房剩余房数HotelInfo;/-枚举类型-enum MainUI,
3、HotelInfoUI,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit;/GUIenum Single,Double,Big;/Room Typeenum Hour,Day;/countType/-全局变量-1 / 12int GUI = MainUI;Order* orderList100;/订单数组Room* roomList100;/房间数组HotelInfo * hotelInfo = NULL;/酒店房间信息/-函数声明-void initiallizeRoomList();void insertToOrderList(Order
4、* order);Room* 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); hot
5、elInfo -> 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+) /单人房房间信息初始化 newRoom = (
7、 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->price=180; ro
8、omListi->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;/通过所选择的房型获取空房间,获取房间后将房间信息改为已入住,并减少相应房型的剩余房间数Roo
9、m* 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)roomListi->
10、;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 insertToOrderList(
11、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("cls");printf(
12、"nn=酒店房间登记与计费管理管理系统=tnnn");printf("*tttt1. 入住登记 tttt*n");printf("*tttt2. 查询入住情况 ttt*n");printf("*tttt3. 查询当前费用 ttt*n");printf("*tttt4. 结账退房 tttt*n");printf("*tttt5. 退出程序 tttt*nnn");printf("nn=酒店房间登记与计费管理管理系统=tnnn");printf("请输
13、入相应编号进入菜单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:break;void showHotelInfoUI()int chooseNum;system("cls&quo
14、t;);printf("nn=酒店入住情况查询菜单=tnnnn");printf("*ttt入住房间数: %dtttt*n", hotelInfo->checkinAmount);printf("*ttt剩余房间数: t");printf("单人房:%dtt*n",hotelInfo->singleRemainAmount);printf("*ttttt双人房:%dtt*n",hotelInfo->doubleRemainAmount);printf("*ttttt大
15、床房:%dtt*nn",hotelInfo->bigRemainAmount);printf("nn=酒店入住情况查询菜单=tnnn");printf("按 0 :返回 n");printf("按 1 : 登记入住n");scanf("%d",&chooseNum);switch(chooseNum)case 0:GUI = MainUI;break;case 1:GUI = CheckinUI;break;default:GUI = HotelInfoUI;break;void showC
16、heckinUI()Order * newOrder;Room* newRoom = NULL;/填写一个新的入住信息CheckinInfo * newCheckinInfo = NULL;int roomTypeNum;int countTypeNum;time_t timep;system("cls");printf("nn=酒店入住登记菜单=tnnn");newCheckinInfo = ( CheckinInfo * )malloc(sizeof(CheckinInfo);printf("*tt请输入姓名:");scanf(&
17、quot;%s", &(newCheckinInfo->name) );printf("*tt请输入证件号:");scanf("%d", &(newCheckinInfo->id) );printf("*tt请选择入住房型:n");printf("ttt1.单人房nttt2.双人房nttt3.大床房n");scanf("%d",&(roomTypeNum);switch(roomTypeNum) /通过输入的数字对应房型case 1:newCheck
18、inInfo->roomType = Single;break;case 2:newCheckinInfo->roomType = Double;break;case 3:newCheckinInfo->roomType = Big;break;default:newCheckinInfo->roomType = Single;break;printf("*tt请选择计费方式:n");printf("ttt1.按小时计费; nttt2.按天数计费n"); /通过输入的数字对应计费方式 scanf("%d",&a
19、mp;countTypeNum);switch(countTypeNum)case 1:newCheckinInfo->countType = Hour;break;case 2:newCheckinInfo->countType = Day;break;printf("nn=酒店入住登记菜单=tnnn");/生成一个新的订单newOrder = ( Order* )malloc(sizeof(Order);newOrder -> checkinInfo = newCheckinInfo;newOrder -> date = time(0);swit
20、ch(newCheckinInfo->roomType) /通过房型获取房间case Single:newRoom = getRoomByType(Single);break;case Double:newRoom=getRoomByType(Double);break;case Big :newRoom=getRoomByType(Big);break;newOrder->room = newRoom;insertToOrderList(newOrder);printf("房间号为:%dn",newOrder->room->roomNum);GUI
21、 = CheckinResultUI;void showCheckinResultUI()int chooseNum;printf("nn=酒店入住登记确认菜单=tnnn");printf("ttt*ttttn");printf("ttt* 登记成功 *ttttn");printf("ttt*ttttnn");printf("nn=酒店入住登记确认菜单=tnnn"); printf("按 0 :返回 n");scanf("%d",&chooseNu
22、m);switch(chooseNum)case 0:GUI = MainUI;break;default:GUI = CheckinResultUI;break;void showOrderUI() int roomNum;int chooseNum;int amount;Order * theOrder = NULL;system("cls");printf("nn=酒店房间信息查询菜单=tnnn");printf("请输入房间号:");scanf("%d",&roomNum);if (roomNum&
23、lt;0 | roomNum>100) printf("n 输入有误请重新输入") ; GUI = OrderUI;elsetheOrder = getOrderByRoomNum(roomNum);printf("房型:");switch(theOrder->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;printf("已入住时间:%d小时n",amount);break;case Day:printf("天计费n")
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 大寒节气幼儿护理
- 传统治疗体系概述
- 智慧城市三维管网设计施工与质量保障服务合同
- 核电站辅助岗位派遣服务及管理协议
- 生物有机肥生产技术许可与售后服务合同
- 文创园区产业孵化与委托经营管理合同
- 游戏动漫IP授权与跨界合作开发合同
- 电池产品安全评估与理赔补充合同
- 伊利集团年度培训体系总结
- 高效节能工业废气处理系统验收质量标准协议
- 喷淋塔设计标准参考
- 国家课程设置标准课时
- 高支模板监测记录
- 涂装工艺流程、PFMEA2018
- 《苏泊尔盈利能力分析》8000字
- 浙教版初中科学所有实验目录及所需器材九上
- 车站信号自动控制教案-四线制道岔控制启动电路
- 数字经济学导论-全套课件
- 委托书挂靠样本
- 大学生职业发展与就业指导学习通课后章节答案期末考试题库2023年
- 立体几何中的空间距离问题
评论
0/150
提交评论