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

下载本文档

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

文档简介

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 HotelRoom/ 计费方式int roomType;/ 房型int roomNum;/ 房号int ch

2、ecked;/ 入住情况int price;Room;typedef struct RoomOrder/ 房价CheckinInfo *checkinInfo;/ 入住信息long date;/ 入住时间Room * room;Order;typedef struct HotelInfomation/ 房间信息int checkinAmount;/ 已入住房数int singleRemainAmount;/ 单人房剩余房数int doubleRemainAmount;/ 双人房剩余房数int bigRemainAmount; HotelInfo;/ 大床房剩余房数/- 枚举类型 -enum M

3、ainUI,HotelInfoUI,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit;/GUIenum Single,Double,Big;/Room Typeenum Hour,Day;/countType/- int GUI = MainUI;全局变量 -Order* orderList100;/ 订单数组Room* roomList100;/ 房间数组HotelInfo * hotelInfo = NULL;/酒店房间信息/- 函数声明 -void initiallizeRoomList();void insertToOrderList(

4、Order * 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(HotelIn

5、fo);hotelInfo -> 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 CheckinU

6、I:showCheckinUI();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)roomList

10、i->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 insertToOrde

11、rList(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")

12、;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=酒店房间登记与计费管理管理系统 =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&

14、quot;);printf("nn=酒店入住情况查询菜单=tnnnn");printf("*ttt入住房间数 : %dtttt*n", hotelInfo->checkinAmount);printf("*ttt剩余房间数 : t");printf(" 单人房: %dtt*n",hotelInfo->singleRemainAmount);printf("*ttttt双人房: %dtt*n",hotelInfo->doubleRemainAmount);printf("

15、;*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;default:GUI = HotelInfoUI;break

16、;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请输入姓名 :&q

17、uot;);scanf("%s", &(newCheckinInfo->name) );printf("*tt请输入证件号 :");scanf("%d", &(newCheckinInfo->id) );printf("*tt请选择入住房型 :n");printf("ttt1.单人房 nttt2.双人房 nttt3.大床房 n");scanf("%d",&(roomTypeNum);switch(roomTypeNum)/ 通过输入的数字对

18、应房型case 1:newCheckinInfo->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");/ 通过输入的数字对应计费方式sca

19、nf("%d",&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 ->

20、; date = time(0);switch(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-&g

21、t;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("%d

22、",&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",&

23、roomNum);if (roomNum<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");amoun

温馨提示

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

评论

0/150

提交评论