酒店管理系统代码_第1页
酒店管理系统代码_第2页
酒店管理系统代码_第3页
酒店管理系统代码_第4页
酒店管理系统代码_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、#include #include #include#include#include/-结构定义-typedef struct CheckinInformationchar name10; /姓名int id; /证件号int roomType; /房型int countType; /计费方式CheckinInfo;typedef struct HotelRoomint roomType; /房型int roomNum; /房号int checked; /入住情况int price; /房价Room;typedef struct RoomOrderCheckinInfo *checkinInf

2、o; /入住信息long date; /入住时间Room * room; /房间信息Order;typedef struct HotelInfomationint checkinAmount; /已入住房数int singleRemainAmount; /单人房剩余房数int doubleRemainAmount; /双人房剩余房数int bigRemainAmount; /大床房剩余房数HotelInfo;/-枚举类型-enum MainUI,HotelInfoUI,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit;/GUIenum Sing

3、le,Double,Big;/Room Typeenum Hour,Day;/countType/-全局变量-int GUI = MainUI;Order* orderList100;/订单数组Room* roomList100;/房间数组HotelInfo * hotelInfo = NULL;/酒店房间信息/-函数声明-void initiallizeRoomList();void insertToOrderList(Order * order);Room* getRoomByType(int roomType);Order* getOrderByRoomNum(int roomNum);

4、void showMainUI();void showHotelInfoUI();void showCheckinUI();void showCheckinResultUI();void showOrderUI();void showCheckOutUI();/-Main函数-void main() /主函数/初始化酒店房间信息hotelInfo = (HotelInfo *)malloc(sizeof(HotelInfo); hotelInfo - singleRemainAmount = 20;hotelInfo - doubleRemainAmount=40;hotelInfo - bi

5、gRemainAmount=40;hotelInfo - checkinAmount=0;/初始化房间列表initiallizeRoomList();/界面显示while(GUI != Exit)switch(GUI)case MainUI:showMainUI();break;case HotelInfoUI:showHotelInfoUI();break;case CheckinUI:showCheckinUI();break;case CheckinResultUI:showCheckinResultUI();break;case OrderUI:showOrderUI();break;

6、case CheckOutUI:showCheckOutUI();break;default: break;/-函数定义-void initiallizeRoomList()/房间数组初始化,初始化的结果是让roomList的数组有100个room指针,而且设置了相应的值int i;Room*newRoom=NULL;for(i=0;ichecked=0; roomListi-price=110; roomListi-roomNum=i+1; roomListi-roomType=Single;for(i=20;ichecked=0; roomListi-price=180; roomList

7、i-roomNum=i+1; roomListi-roomType=Double;for(i=60;ichecked=0; roomListi-price=180; roomListi-roomNum=i+1; roomListi-roomType=Big;/通过所选择的房型获取空房间,获取房间后将房间信息改为已入住,并减少相应房型的剩余房间数Room* getRoomByType(int roomType)int i;switch(roomType)case Single:for(i=0;ichecked = 0)roomListi-checked=1;hotelInfo-singleRem

8、ainAmount - ;hotelInfo-checkinAmount+;return roomListi;break;case Double:for(i=20;ichecked = 0)roomListi-checked=1;hotelInfo-doubleRemainAmount - ;hotelInfo-checkinAmount+;return roomListi;break;case Big:for(i=60;ichecked = 0)roomListi-checked=1;hotelInfo-bigRemainAmount -;hotelInfo-checkinAmount+;r

9、eturn roomListi;break;/将订单放入订单列表void insertToOrderList(Order * order)int i;for( i = 0;i100;i+)if( orderListi =NULL )orderListi = order;break;/通过房号查询订单Order* getOrderByRoomNum(int roomNum)int i;for(i=0;iroom-roomNum = roomNum)return orderListi;void showMainUI()/显示主界面,并接受输入int chooseNum;system(cls);pr

10、intf(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(请输入相应编号进入菜单t);/接受输入scanf(%d,&chooseNum);switch(chooseNum)case 1:GUI = HotelInfoUI;break

11、;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);printf(nn=酒店入住情况查询菜单=tnnnn);printf(*ttt入住房间数: %dtttt*n, hotelInfo-checkinAmount);printf(*ttt剩余房间数: t);printf(单人房:%d

12、tt*n,hotelInfo-singleRemainAmount);printf(*ttttt双人房:%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 0:GUI = MainUI;break;case 1:GUI = CheckinUI;break;d

13、efault: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);newCheckinInfo = ( CheckinInfo * )malloc(sizeof(CheckinInfo);printf(*tt请输入姓名:);sc

14、anf(%s, &(newCheckinInfo-name) );printf(*tt请输入证件号:);scanf(%d, &(newCheckinInfo-id) );printf(*tt请选择入住房型:n);printf(ttt1.单人房nttt2.双人房nttt3.大床房n);scanf(%d,&(roomTypeNum);switch(roomTypeNum) /通过输入的数字对应房型case 1:newCheckinInfo-roomType = Single;break;case 2:newCheckinInfo-roomType = Double;break;case 3:new

15、CheckinInfo-roomType = Big;break;default:newCheckinInfo-roomType = Single;break;printf(*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=酒店入住登记菜

16、单=tnnn);/生成一个新的订单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)

17、;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);printf(ttt*ttttnn);printf(nn=酒店入住登记确认菜单=tnnn); printf(按 0 :返回 n);scanf

18、(%d,&chooseNum);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 (roomNum100) printf(n 输入有误请重新输入) ; GUI = OrderUI

19、;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);b

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论