酒店管理系统代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#includewindows.h#includedos.h#includestdio.h#includestdlib.h#includetime.h//--------------------------------------------------结构定义------------------------------------------typedefstructCheckinInformation{charname[10];//姓名intid;//证件号introomType;//房型intcountType;//计费方式}CheckinInfo;typedefstructHotelRoom{introomType;//房型introomNum;//房号intchecked;//入住情况intprice;//房价}Room;typedefstructRoomOrder{CheckinInfo*checkinInfo;//入住信息longdate;//入住时间Room*room;//房间信息}Order;typedefstructHotelInfomation{intcheckinAmount;//已入住房数intsingleRemainAmount;//单人房剩余房数intdoubleRemainAmount;//双人房剩余房数intbigRemainAmount;//大床房剩余房数}HotelInfo;//--------------------------------枚举类型---------------------------enum{MainUI,HotelInfoUI,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit};//GUIenum{Single,Double,Big};//RoomTypeenum{Hour,Day};//countType//--------------------------------全局变量--------------------------intGUI=MainUI;Order*orderList[100];//订单数组Room*roomList[100];//房间数组HotelInfo*hotelInfo=NULL;//酒店房间信息//-------------------------------函数声明----------------------------voidinitiallizeRoomList();voidinsertToOrderList(Order*order);Room*getRoomByType(introomType);Order*getOrderByRoomNum(introomNum);voidshowMainUI();voidshowHotelInfoUI();voidshowCheckinUI();voidshowCheckinResultUI();voidshowOrderUI();voidshowCheckOutUI();//-------------------------------Main函数----------------------------voidmain()//主函数{//初始化酒店房间信息hotelInfo=(HotelInfo*)malloc(sizeof(HotelInfo));hotelInfo-singleRemainAmount=20;hotelInfo-doubleRemainAmount=40;hotelInfo-bigRemainAmount=40;hotelInfo-checkinAmount=0;//初始化房间列表initiallizeRoomList();//界面显示while(GUI!=Exit){switch(GUI){caseMainUI:showMainUI();break;caseHotelInfoUI:showHotelInfoUI();break;caseCheckinUI:showCheckinUI();break;caseCheckinResultUI:showCheckinResultUI();break;caseOrderUI:showOrderUI();break;caseCheckOutUI:showCheckOutUI();break;default:break;}}}//-------------------------------函数定义----------------------------voidinitiallizeRoomList(){//房间数组初始化,初始化的结果是让roomList的数组有100个room指针,而且设置了相应的值inti;Room*newRoom=NULL;for(i=0;i20;i++)//单人房房间信息初始化{newRoom=(Room*)malloc(sizeof(Room));roomList[i]=newRoom;roomList[i]-checked=0;roomList[i]-price=110;roomList[i]-roomNum=i+1;roomList[i]-roomType=Single;}for(i=20;i60;i++)//双人房房间信息初始化{newRoom=(Room*)malloc(sizeof(Room));roomList[i]=newRoom;roomList[i]-checked=0;roomList[i]-price=180;roomList[i]-roomNum=i+1;roomList[i]-roomType=Double;}for(i=60;i100;i++)//大床房房间信息初始化{newRoom=(Room*)malloc(sizeof(Room));roomList[i]=newRoom;roomList[i]-checked=0;roomList[i]-price=180;roomList[i]-roomNum=i+1;roomList[i]-roomType=Big;}}//通过所选择的房型获取空房间,获取房间后将房间信息改为已入住,并减少相应房型的剩余房间数Room*getRoomByType(introomType){inti;switch(roomType){caseSingle:for(i=0;i20;i++){if(roomList[i]-checked==0){roomList[i]-checked=1;hotelInfo-singleRemainAmount--;hotelInfo-checkinAmount++;returnroomList[i];}}break;caseDouble:for(i=20;i60;i++){if(roomList[i]-checked==0){roomList[i]-checked=1;hotelInfo-doubleRemainAmount--;hotelInfo-checkinAmount++;returnroomList[i];}}break;caseBig:for(i=60;i100;i++){if(roomList[i]-checked==0){roomList[i]-checked=1;hotelInfo-bigRemainAmount--;hotelInfo-checkinAmount++;returnroomList[i];}}break;}}//将订单放入订单列表voidinsertToOrderList(Order*order){inti;for(i=0;i100;i++){if(orderList[i]==NULL){orderList[i]=order;break;}}}//通过房号查询订单Order*getOrderByRoomNum(introomNum){inti;for(i=0;i100;i++){if(orderList[i]-room-roomNum==roomNum){returnorderList[i];}}}voidshowMainUI(){//显示主界面,并接受输入intchooseNum;system(cls);printf(\n\n==========================酒店房间登记与计费管理管理系统=======================\t\n\n\n);printf(*\t\t\t\t1.入住登记\t\t\t\t*\n);printf(*\t\t\t\t2.查询入住情况\t\t\t*\n);printf(*\t\t\t\t3.查询当前费用\t\t\t*\n);printf(*\t\t\t\t4.结账退房\t\t\t\t*\n);printf(*\t\t\t\t5.退出程序\t\t\t\t*\n\n\n);printf(\n\n==========================酒店房间登记与计费管理管理系统=======================\t\n\n\n);printf(请输入相应编号进入菜单\t);//接受输入scanf(%d,&chooseNum);switch(chooseNum){case1:GUI=HotelInfoUI;break;case2:GUI=HotelInfoUI;break;case3:GUI=OrderUI;break;case4:GUI=OrderUI;break;case5:Sleep(3000);GUI=Exit;break;default:break;}}voidshowHotelInfoUI(){intchooseNum;system(cls);printf(\n\n=========================酒店入住情况查询菜单=======================\t\n\n\n\n);printf(*\t\t\t入住房间数:%d\t\t\t\t*\n,hotelInfo-checkinAmount);printf(*\t\t\t剩余房间数:\t);printf(单人房:%d\t\t*\n,hotelInfo-singleRemainAmount);printf(*\t\t\t\t\t双人房:%d\t\t*\n,hotelInfo-doubleRemainAmount);printf(*\t\t\t\t\t大床房:%d\t\t*\n\n,hotelInfo-bigRemainAmount);printf(\n\n=========================酒店入住情况查询菜单=======================\t\n\n\n);printf(按0:返回\n);printf(按1:登记入住\n);scanf(%d,&chooseNum);switch(chooseNum){case0:GUI=MainUI;break;case1:GUI=CheckinUI;break;default:GUI=HotelInfoUI;break;}}voidshowCheckinUI(){Order*newOrder;Room*newRoom=NULL;//填写一个新的入住信息CheckinInfo*newCheckinInfo=NULL;introomTypeNum;intcountTypeNum;time_ttimep;system(cls);printf(\n\n===========================酒店入住登记菜单=========================\t\n\n\n);newCheckinInfo=(CheckinInfo*)malloc(sizeof(CheckinInfo));printf(

1 / 12
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功