資源簡介
1.添加酒店資料
2.刪除酒店資料
3.增加訂單
4.取消訂單
5.查找城市酒店
6.瀏覽所有酒店
7.瀏覽所有訂單
8.退出酒店系統
酒店資料: 酒店編號(自動生成),酒店名稱,所在城市,總房數,普通房數,普通空房數,普通房價,
高級房數,高級空房數,高級房價
訂單:訂單編號(自動生成),酒店編號,房間類型,訂房數目,訂者姓名,聯系電話,email地址
要求:
1、增加訂單時訂房數目必須小于此類型酒店的空房數,有了訂單后,酒店的空房數應相應減少,取消訂單后相應增加。(由于沒有對訂單的日期做比較,所有訂單長期有效,和實際情況有所出入)
2、查詢資料時,輸出的資料應格式化對齊。臺頭有中文說明。
3、使用類來定義酒店資料和訂單資料,并且對<>(輸入)運算符進行重載,以格式化輸出。
4、菜單選擇錯誤時,有退出機制,不需要完成菜單項的內容也可以退出。
5、所有資料保存在文件中。
6、使用STL類庫來添加和刪除資料。
7、代碼中有足夠的注釋,可以讓開發者以外的人很快看明白。
8、使用頭文件和源代碼分開的形式。(2個文件,1個.h,一個.cpp)
9、對輸入有校驗,如輸入的類型不對,應該有提示重新輸入。

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include
#include?“HotelInfo.h“
#include?“HotelOrder.h“
using?namespace?std;
int?Add_Hotel()
{
list?hotel_list;
HotelInfo?hotel;
if(hotel.InputInfo()==-1)
return?-1;
hotel_list.push_back(hotel);
SaveFile(hotel_listtrue);
return?0;
}
void?Del_Hotel()
{
list?del_list;
HotelInfo?del;
LoadFile(del_list);
int?flag=0rid;
string?id;
cout<<“請輸入要刪除的酒店編號:“;
cin>>id;
while(1)
{
if?(checknum(id)||Inputcheck(id))
{
break;
}
else
{
???? cout<<“您的輸入不正確,請重新輸入!!!“< cout<<“請輸入對應數字:“;
cin>>id;
}
}
rid=atoi(id.c_str());
list::iterator?it=del_list.begin();
while?(it!=del_list.end())
{
if?(it->m_HId==rid)
{
flag=1;
del_list.erase(it);
SaveFile(del_listfalse);
return;
}
it++;
}
if?(flag==0)
{
cout<<“您要刪除的酒店編號不存在!!!“< }
}
int?Add_Order()
{
list?AddO;
HotelOrder?AO;
if(AO.Inputinfo()==-1)
return?-1;
AddO.push_back(AO);
SaveFile_O(AddOtrue);
return?0;
}
void?Cancel_Order()
{
int?tmp_hid;
list?can_o;
list?h_list;
LoadFile(h_list);
HotelInfo?can;
LoadFile_O(can_o);
int?flag=0flag1=0;
string?id;
cout<<“請輸入要刪除的訂單編號:“;
cin>>id;
while(1)
{
if?(CheckReOid(id)||Inputcheck(id))
{
break;
}
else
{
cout<<“您的輸入的訂單編號不存在!!!“< cout<<“請輸入對應數字:“;
cin>>id;
}
}
list::iterator?it1=h_list.begin();
list::iterator?it=can_o.begin();
while?(it!=can_o.end())
{
if?(it->m_OId==id)
{
tmp_hid=it->m_HId;
while?(it1!=h_list.end())
{
if?(it1->m_HId==tmp_hid)
{
flag1=1;
break;
}
it1++;
}
if?(flag1==0)
{
string?x;
cout<<“您要刪除的訂單對應的酒店已經不存在了!!!“< cout<<“您是否要繼續刪除訂單,(Y/N):“;
cin>>x;
if?(x==“y“||x==“Y“)
{
can_o.erase(it);
SaveFile_O(can_ofalse);
return;
}
else
{
break;
}
}
if(flag1==1)
{
flag=1;
UpdataInfo_order(h_listit->m_ORoomTypeit->m_HIdit->m_ONum);
SaveFile(h_listfalse);
can_o.erase(it);
SaveFile_O(can_ofalse);
break;
}
}
it++;
}
if(flag==1)
{
cout<<“刪除訂單成功!!!“< }
}
void?Search_City()
{
list?H_Search;
HotelInfo?search;
LoadFile(H_Search);
string?city;
int?kflag=0;
k=CountLines(“test.txt“);
if(k>0)
{
list::iterator?it=H_Search.begin();
cout<<“根據城市查找酒店:“;
cin>>city;
cout<<“酒店編號“< <<“普通空房數“< while(it!=H_Search.end())
{
if?(it->m_Hcity==city)
{
flag=1;
cout<m_HId<m_Hname<m_Hcity<
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-08-24?09:41??Hotel\
?????目錄???????????0??2011-08-24?09:41??Hotel\Debug\
?????文件?????2794496??2011-08-23?16:54??Hotel\Debug\Hotel.bsc
?????文件??????696403??2011-08-23?16:54??Hotel\Debug\Hotel.exe
?????文件?????1298164??2011-08-23?16:54??Hotel\Debug\Hotel.ilk
?????文件??????284299??2011-08-23?15:07??Hotel\Debug\Hotel.obj
?????文件?????2616480??2011-08-23?15:34??Hotel\Debug\Hotel.pch
?????文件?????1532928??2011-08-23?16:45??Hotel\Debug\Hotel.pdb
?????文件???????????0??2011-08-23?15:07??Hotel\Debug\Hotel.sbr
?????文件??????460427??2011-08-23?16:22??Hotel\Debug\HotelInfo.obj
?????文件???????????0??2011-08-23?16:22??Hotel\Debug\HotelInfo.sbr
?????文件??????460017??2011-08-23?16:54??Hotel\Debug\HotelOrder.obj
?????文件???????????0??2011-08-23?16:54??Hotel\Debug\HotelOrder.sbr
?????文件??????238592??2011-08-23?16:54??Hotel\Debug\vc60.idb
?????文件??????176128??2011-08-23?16:45??Hotel\Debug\vc60.pdb
?????文件????????5918??2011-08-23?14:50??Hotel\Hotel.cpp
?????文件????????4532??2011-08-20?16:41??Hotel\Hotel.dsp
?????文件?????????518??2011-08-20?10:13??Hotel\Hotel.dsw
?????文件???????74752??2011-08-23?16:54??Hotel\Hotel.ncb
?????文件???????55808??2011-08-23?16:54??Hotel\Hotel.opt
?????文件?????????433??2011-08-23?16:54??Hotel\Hotel.plg
?????文件????????8093??2011-08-23?15:34??Hotel\HotelInfo.cpp
?????文件????????1721??2011-08-23?15:06??Hotel\HotelInfo.h
?????文件????????6779??2011-08-23?16:54??Hotel\HotelOrder.cpp
?????文件?????????997??2011-08-22?23:12??Hotel\HotelOrder.h
?????文件??????????51??2011-08-23?16:47??Hotel\order.txt
?????文件??????????47??2011-08-23?16:47??Hotel\test.txt
?????文件?????????323??2011-08-24?10:17??Hotel\復件?test.txt
- 上一篇:c++prime課后習題答案PDF版
- 下一篇:計算機考研復試問題匯總帶答案
評論
共有 條評論