酒店管理系統代碼_第1頁
酒店管理系統代碼_第2頁
酒店管理系統代碼_第3頁
酒店管理系統代碼_第4頁
酒店管理系統代碼_第5頁
已閱讀5頁,還剩7頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

#include<windows.h>#include<dos.h>#include<stdio.h>#include<stdlib.h>#include<time.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; } break; caseBig: for(i=60;i<100;i++) { if(roomList[i]->checked==0) { roomList[i]->checked=1; hotelInfo->bigRemainAmount--; hotelInfo->checkinAmount++; returnroomList[i]; } } break; } }//將訂單放入訂單列表voidinsertToOrderList(Order*order){ inti; for(i=0;i<100;i++) { if(orderList[i]==NULL) { orderList[i]=order; break; } } }//通過房號查詢訂單Order*getOrderByRoomNum(introomNum){ inti; for(i=0;i<100;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("*\t\t請輸入姓名:"); scanf("%s",&(newCheckinInfo->name)); printf("*\t\t請輸入證件號:"); scanf("%d",&(newCheckinInfo->id)); printf("*\t\t請選擇入住房型:\n"); printf("\t\t\t1.單人房\n\t\t\t2.雙人房\n\t\t\t3.大床房\n"); scanf("%d",&(roomTypeNum)); switch(roomTypeNum)//通過輸入的數字對應房型 { case1: newCheckinInfo->roomType=Single; break; case2: newCheckinInfo->roomType=Double; break; case3: newCheckinInfo->roomType=Big; break; default: newCheckinInfo->roomType=Single; break; } printf("*\t\t請選擇計費方式:\n"); printf("\t\t\t1.按小時計費;\n\t\t\t2.按天數計費\n");//通過輸入的數字對應計費方式scanf("%d",&countTypeNum); switch(countTypeNum) { case1: newCheckinInfo->countType=Hour; break; case2: newCheckinInfo->countType=Day; break; } printf("\n\n===========================酒店入住登記菜單=========================\t\n\n\n"); //生成一個新的訂單 newOrder=(Order*)malloc(sizeof(Order)); newOrder->checkinInfo=newCheckinInfo; newOrder->date=time(0); switch(newCheckinInfo->roomType)//通過房型獲取房間 { caseSingle: newRoom=getRoomByType(Single); break; caseDouble: newRoom=getRoomByType(Double); break; caseBig: newRoom=getRoomByType(Big); break; } newOrder->room=newRoom; insertToOrderList(newOrder); printf("房間號為:%d\n",newOrder->room->roomNum); GUI=CheckinResultUI;}voidshowCheckinResultUI(){ intchooseNum; printf("\n\n=========================酒店入住登記確認菜單=======================\t\n\n\n"); printf("\t\t\t************\t\t\t\t\n"); printf("\t\t\t*登記成功*\t\t\t\t\n"); printf("\t\t\t************\t\t\t\t\n\n"); printf("\n\n=========================酒店入住登記確認菜單=======================\t\n\n\n");printf("按0:返回\n"); scanf("%d",&chooseNum); switch(chooseNum) { case0: GUI=MainUI; break; default: GUI=CheckinResultUI; break; }}voidshowOrderUI(){ introomNum; intchooseNum; intamount; Order*theOrder=NULL; system("cls"); printf("\n\n=========================酒店房間信息查詢菜單=======================\t\n\n\n"); printf("請輸入房間號:"); scanf("%d",&roomNum); if(roomNum<0||roomNum>100) { printf("\n輸入有誤請重新輸入"); GUI=OrderUI; } else { theOrder=getOrderByRoomNum(roomNum); printf("房型:"); switch(theOrder->room->roomType) { caseSingle: printf("單人房\n");break; caseDouble: printf("雙人房\n");break; caseBig: printf("大床房\n");break; } printf("計費方式:"); switch(theOrder->checkinInfo->countType) { caseHour: printf("小時計費\n"); amount=(time(0)-theOrder->date)/3600+1; printf("已入住時間:%d小時\n",amount); break; caseDay: printf("天計費\n"); amount=(time(0)-theOrder->date)/(3600*24)+1; printf("已入住時間:%d天\n",amount); break; } printf("房價:%d\n",theOrder->room->price); print

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論