C++版酒店管理程序代碼培訓(xùn)講學(xué)_第1頁(yè)
C++版酒店管理程序代碼培訓(xùn)講學(xué)_第2頁(yè)
C++版酒店管理程序代碼培訓(xùn)講學(xué)_第3頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余9頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、程序代碼N:最終改進(jìn)版代碼(利用結(jié)構(gòu)體儲(chǔ)存多種類型的數(shù)據(jù))好處:比數(shù)組能儲(chǔ)存更多類型的數(shù)據(jù)!#include#include#include常用函數(shù)庫(kù)usingnamespacestd;/*在c+中struct和類的區(qū)別在于struct不能有方法,所有成員是public的*/structRoomintNumber;intPrice;intState;intdays;stringName;stringPhone;stringID;/room;可以在聲明struct的時(shí)候聲明一個(gè)struct實(shí)例Roomroom80;classBookRoom定義預(yù)定房間類(private:stringcName;

2、顧客姓名intstayTime;預(yù)定天數(shù)introomType;房間類型(1.標(biāo)準(zhǔn)單人問(wèn)2.大床房3.標(biāo)準(zhǔn)雙人問(wèn)4.套房)stringphoneNum;/預(yù)留手機(jī)號(hào)public:voidsetData()(stringname;inttime;inttype;stringnum;cout”您好,請(qǐng)輸入您的姓名:name;cName=name;cout”預(yù)定天數(shù)為:time;stayTime=time;cout想要預(yù)定的房間類型:1.標(biāo)準(zhǔn)單人問(wèn)100/天2.大床房200/天3.標(biāo)準(zhǔn)雙人問(wèn)300/天4.套房400/天”type;roomType=type;cout預(yù)留手機(jī)號(hào):num;phoneNu

3、m=num;voidBook()(cout正在預(yù)定.roomType)(case1:for(inti=0;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;cout預(yù)定成功!房間號(hào):roomi.Numberendlendl;roomi.State=1;break;已被預(yù)訂elsecoutroomi.Number號(hào)房間已有人endl;break;case2:for(inti=20;istayTime;roomi.Name=this-cName;roomi.Phone=this-

4、phoneNum;roomi.Price*=this-stayTime;cout預(yù)定成功!房間號(hào):roomi.Numberendlendl;roomi.State=1;break;elsecoutroomi.Number號(hào)房間已有人endl;break;case3:for(inti=40;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;cout預(yù)定成功!房間號(hào):roomi.Numberendlendl;roomi.State=1;break;elsecoutroomi.Nu

5、mber號(hào)房間已有人endl;break;case4:for(inti=60;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;cout預(yù)定成功!房間號(hào):roomi.Numberendlendl;roomi.State=1;break;elsecoutroomi.Number號(hào)房間已有人endl;break;default:cout您輸入的房間類型有誤!endl;classCheckIn定義辦理入住類(private:stringcName;stringcSex;string

6、idNum;身份證號(hào)intcheck_inDate;入住日期intstayTime;introomType;stringphoneNum;public:voidunbooked()stringname;stringsex;stringidnum;intdate;inttime;inttype;stringnum;cout客戶姓名:name;cName=name;cout客戶性別:sex;cSex=sex;cout客戶身份證號(hào):idnum;idNum=idnum;cout入住日期:date;check_inDate=date;cout占用天數(shù):time;stayTime=time;cout房間類

7、型:1.標(biāo)準(zhǔn)單人問(wèn)100/天2.大床房200/天3.標(biāo)準(zhǔn)雙人問(wèn)300/天4.套房400/天type;roomType=type;cout客戶手機(jī)號(hào):num;phoneNum=num;switch(this-roomType)(case1:for(inti=0;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;roomi.ID=this-idNum;cout入住成功!房間號(hào):roomi.Numberendlendl;cout請(qǐng)支付200元押金endlendl;roomi.Sta

8、te=1;break;elsecout抱歉,該房間類型沒(méi)有了endl;break;case2:for(inti=20;istayTime;roomi.Name=this-cName;roomi.Price*=this-stayTime;roomi.ID=this-idNum;cout入住成功!房間號(hào):roomi.Numberendlendl;cout請(qǐng)支付400元押金endlendl;roomi.State=1;break;elsecout抱歉,該房間類型沒(méi)有了endl;break;case3:for(inti=40;istayTime;roomi.Name=this-cName;roomi.

9、Phone=this-phoneNum;roomi.Price*=this-stayTime;roomi.ID=this-idNum;cout入住成功!房間號(hào):roomi.Numberendlendl;cout請(qǐng)支付600元押金endlendl;roomi.State=1;break;elsecout抱歉,該房間類型沒(méi)有了endl;break;case4:for(inti=60;istayTime;roomi.Name=this-cName;roomi.Phone=this-phoneNum;roomi.Price*=this-stayTime;roomi.ID=this-idNum;cout

10、入住成功!房間號(hào):roomi.Numberendlendl;cout請(qǐng)支付800元押金endlendl;roomi.State=1;break;elsecout抱歉,該房間類型沒(méi)有了endl;break;default:cout您輸入的房間類型有誤!endl;voidbooked()stringcompareitem;stringid_num;cout請(qǐng)輸入您的姓名或者手機(jī)號(hào):compareitem;for(inti=0;i80;i+)(if(roomi.Name=compareitem|roomi.Phone=compareitem)(cout驗(yàn)證成功!請(qǐng)支付:(roomi.Price*2)

11、元押金endl;cout請(qǐng)登記客戶的身份證號(hào):id_num;idNum=id_num;roomi.iD=idNum;cout房間號(hào)為:roomi.Numberendl歡迎入?。ndlendl;break;classcheckOut(private:stringname;intnumber;intdays;intprice;public:voidcheckout()(intexpense;cout請(qǐng)輸入房間號(hào):number;cout請(qǐng)輸入姓名:name;cout請(qǐng)輸入實(shí)際住宿天數(shù):days;for(inti=0;i80;i+)if(roomi.Name=name)&(roomi.Number=

12、number)expense=days*(roomi.Number/100*100);cout房間號(hào)為roomi.Number”的房間實(shí)際消費(fèi)為expense元endl;cout押金為:roomi.Priceroomi.Price)cout請(qǐng)補(bǔ)交(expense-roomi.Price)元endl;elsecout退回:(roomi.Price-expense)元endl;break;elsecoutroomi.Number”號(hào)房不符合endl;cout房費(fèi)核算活后請(qǐng)安任意鍵繼續(xù)endlendl;system(pause);cout感謝入住本灑店,歡迎下次光臨!endlendl;voidmen

13、u()cout歡迎使用灑店管理系統(tǒng)!endl;cout請(qǐng)選擇:endl;cout1.預(yù)定房間endl;cout2.辦理入住endl;cout3.退房結(jié)賬endl;cout4.退出系統(tǒng)endl;voidinit()intn=101:for(inti=0;i20;i+)roomi.Number=n+;roomi.Price=100;roomi.State=0;)n=201;roomi.Number=n+;roomi.Price=200;roomi.State=0;n=301;for(inti=40;i60;i+)(roomi.Number=n+;roomi.Price=300;roomi.Stat

14、e=0;n=401;for(inti=60;ic;switch(c)(case1:(BookRoom*a=newBookRoom;a-setData();a-Book();break;case2:(CheckIn*b=newCheckIn;cout您有預(yù)定嗎?1.已預(yù)定2.未預(yù)定”c;switch(c)(case1:(b-booked();break;case2:(b-unbooked();break;default:cout”輸入有誤!checkout();break;case4:cout謝謝使用,再見(jiàn)!endl;flag=0;break;default:cout輸入有誤!endl;retu

15、rn0;O:最初廢除版(利用數(shù)組)因?yàn)閿?shù)組只能簡(jiǎn)單的儲(chǔ)存一種類型的數(shù)據(jù),例如字符和數(shù)字。而灑店管理系統(tǒng)這種情境,一個(gè)房間要儲(chǔ)存多種數(shù)據(jù),例如客戶姓名、客戶性別、預(yù)訂房間號(hào)、客戶預(yù)留手機(jī)號(hào)、客戶占用天數(shù)、客戶身份證號(hào)以及押金和實(shí)際花銷等。因此我選用了結(jié)構(gòu)體來(lái)儲(chǔ)存。以下是Oldversion:#include#includeusingnamespacestd;introom_num420;定義數(shù)組,共4個(gè)樓層,每個(gè)樓層20個(gè)房間,一層一類classBookRoom(private:定義預(yù)定房間類stringcName;顧客姓名intstayTime;預(yù)定天數(shù)introomType;房間類型(1.標(biāo)

16、準(zhǔn)單人問(wèn)2.大床房3.標(biāo)準(zhǔn)雙人問(wèn)4.套房)stringphoneNum;/預(yù)留手機(jī)號(hào)(也可使用longint)public:voidsetData()(stringname;inttime;inttype;stringnum;cout”您好,請(qǐng)輸入您的姓名:name;cName=name;cout”預(yù)定天數(shù)為:time;stayTime=time;cout想要預(yù)定的房間類型:1.標(biāo)準(zhǔn)單人問(wèn)2.大床房3.標(biāo)準(zhǔn)雙人問(wèn)4.套房type;roomType=type;cout預(yù)留手機(jī)號(hào):num;phoneNum=num;voidBook()cout正在預(yù)定.vvendl;switch(this-room

17、Type)case1:for(inti=0;i20;i+)if(room_num1i=0)房間無(wú)人占用且無(wú)人預(yù)定(cout預(yù)定成功!房間號(hào):10i+1endl;room_num1i=1;break;已被預(yù)訂elsecout該類型房間沒(méi)有了endl;)break;case2:for(inti=0;i20;i+)if(room_num2i=0)cout預(yù)定成功!房間號(hào):20i+1endl;room_num2i=1;break;)elsecout該類型房間沒(méi)有了endl;break;case3:for(inti=0;i20;i+)(if(room_num3i=0)(cout預(yù)定成功!房間號(hào):30”i

18、+1endl;room_num3i=1;break;elsecout該類型房間沒(méi)有了endl;break;case4:for(inti=0;i20;i+)(if(room_num4i=0)(cout預(yù)定成功!房間號(hào):40i+1endl;room_num4i=1;break;elsecout該類型房間沒(méi)有了endl;break;default:cout您輸入的房間類型有誤!endl;classCheckin定義辦理入住類(private:stringcName;stringcSex;stringcId;身份證號(hào)stringphoneNum;intcheck_inDate;/入住時(shí)間intstay

19、Time;intRoom_num;public:voidsetData()(stringname;stringsex;stringid;stringnum;intdate;inttime;introom_num;cout客戶姓名:endl;cinname;cName=name;cout性別:endl;cinsex;cSex=sex;cout身份證號(hào):endl;cinid;cld=id;cout手機(jī)號(hào):endl;cinnum;phoneNum=num;cout登記入住時(shí)間:endl;cindate;check_inDate=date;cout入住天數(shù):endl;cintime;stayTime=time;

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論