c++課程設(shè)計-車票管理系統(tǒng)_第1頁
c++課程設(shè)計-車票管理系統(tǒng)_第2頁
c++課程設(shè)計-車票管理系統(tǒng)_第3頁
c++課程設(shè)計-車票管理系統(tǒng)_第4頁
c++課程設(shè)計-車票管理系統(tǒng)_第5頁
已閱讀5頁,還剩9頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、void Bus_link:input()Bus_infor *p,*p2=NULL;p=head;int n;while(p-next)p=p-next;while(n)p2=new Bus_infor;p2-input();p-next=p2;p2-next=NULL;p=p-next;Bus_link:setkey(1);coutn;#include /數(shù)據(jù)流輸入輸出#include/文件輸入輸出#include/字符串操作#include/參數(shù)化輸入輸出#include/時間庫函數(shù)using namespace std;/命名空間class Bus_inforprivate: stat

2、ic int Bus_No;/靜態(tài)數(shù)據(jù)成員,統(tǒng)計當(dāng)前所有的Bus_infor對象的數(shù)目char start20;/起點站char end20;/終點站int Bus_order;/班次號 int all_tickted;/額定載量int tickted;/已定票人數(shù)int Hour_start,Minute_start;/發(fā)車時間float GoHour;/行車時間public:Bus_infor();Bus_infor();Bus_infor *next;void input();/錄入函數(shù) void input(ifstream & is);/讀取函數(shù) void output();/輸出函

3、數(shù)void output(ofstream & os);/寫入函數(shù)void Order_tickt(int n);/定票函數(shù)void Unorder_tickt(int n);/退票函數(shù)void GetTime_start();/獲取發(fā)車時間函數(shù)bool GetTime();/判斷當(dāng)前班次狀況函數(shù)int Get_all_tickted() return all_tickted; /內(nèi)聯(lián)函數(shù),返回額定載量 int Get_tickted() return tickted; /返回已定票人數(shù)int Get_bus_order() return Bus_order; /返回班次號string Get

4、_end()const;/返回終點站的字符串;int Bus_infor:Bus_No=1;Bus_infor:Bus_infor() Bus_No+; tickted=0;Bus_infor:Bus_infor() Bus_No-;void Bus_infor:input()coutttt按提示輸入:endl;coutBus_order;if (cin.fail()/判斷輸入的數(shù)據(jù)類型是否有錯cout n班次輸入錯誤,請重新輸入:;cin.clear();cin.get();else break;coutall_tickted;if (cin.fail()/判斷輸入的數(shù)據(jù)類型是否有錯cout

5、 n座位數(shù)輸入錯誤,請重新輸入:;cin.clear();cin.get();else break;GetTime_start();coutGoHour;if (cin.fail()/判斷輸入的數(shù)據(jù)類型是否有錯cout n行車時間輸入錯誤,請重新輸入:;cin.clear();cin.get();else break;coutstart;cinend;couta;if(a=y|a=Y) tickted=0;void Bus_infor:input(ifstream & is) isBus_orderHour_startMinute_startstartendGoHourall_ticktedt

6、ickted;is.get(); void Bus_infor:output()cout Bus_ordert;if(Minute_start=0)/判斷發(fā)車時的分鐘時刻,若為分則在后面多顯示個,以符合時間格式coutHour_start: Minute_start0t;elsecoutHour_start: Minute_startt;coutstarttend tGoHourt all_ticktedt tickted; if(!GetTime()coutt 此班已出發(fā)endl;elsecoutt 此班未出發(fā)endl;void Bus_infor:output(ofstream & os)

7、 ossetw(6)Bus_order/setw()設(shè)置輸出寬度setw(15)Hour_startsetw(15)Minute_startsetw(15)startsetw(6)endsetw(15)GoHoursetw(15)all_ticktedsetw(15)ticktedendl;void Bus_infor:GetTime_start()coutHour_startMinute_start;if (cin.fail()/判斷輸入的數(shù)據(jù)類型是否有錯cout n時間輸入錯誤,請重新輸入:;cin.clear();cin.get();else if(Hour_start24|Minute

8、_start60)couttm_hourtm_hour=Hour_start & local-tm_minnext=NULL;key=0;/帶參數(shù)的構(gòu)造函數(shù)Bus_link()delete head;/析構(gòu)函數(shù)void input();/錄入車票信息void mend();/修改車票信息void del();/刪除車票信息int find(Bus_infor *p,int num,char *pn);/查找函數(shù) void found();/查詢車票信息void show();/顯示車票信息 void Order();/定購車票信息 void Unorder();/退還車票信息 void sav

9、e();/保存車票信息 void begin();/初始化車票信息 void clear();/清除函數(shù)void about();/關(guān)于車票信息 char mainmenu();/主菜單函數(shù) void setkey(int k) key=k; /設(shè)置系統(tǒng)修改標(biāo)志 int getkey() return key;/返回系統(tǒng)修改標(biāo)志private: Bus_infor *head; /鏈表指針 int key;/系統(tǒng)修改標(biāo)志int password;/管理員登陸標(biāo)志;void Bus_link:input()if(password=1)Bus_infor *p,*p2=NULL;p=head; i

10、nt n=1; /int n;while(p-next)p=p-next;while(n)p2=new Bus_infor;p2-input();p-next=p2;p2-next=NULL;p=p-next; Bus_link:setkey(1);coutn;if(!cin)throw string(數(shù)據(jù)輸入錯誤);elsecoutntt對不起,游客不能錄入車票信息endl;void Bus_link:show()cout客車基本信息如下:endl 班次發(fā)車時間 起點站 終點站 行車時間額定載量已定票人數(shù)當(dāng)前狀況next)(p-next)-output();p=p-next;void Bus

11、_link:found()Bus_infor *p;int num,n;char name20;docoutn;if(!cin)throw string(數(shù)據(jù)輸入錯誤);while(n2);if(n=1)coutnum;if(!cin)throw string(數(shù)據(jù)輸入錯誤);if(n=2)coutname;if(!find(&p,num,name)couttt找不到你要查找的內(nèi)容!next)(*p1)=p;if( (p-next)-Get_bus_order()=num| (p-next)-Get_end()=pn )cout客車基本信息如下:endl 班次發(fā)車時間 起點站 終點站 行車時間

12、額定載量已定票人數(shù)當(dāng)前狀況next)-output(); t=1;p=p-next;return t;void Bus_link:del()if(password=1)Bus_infor *p,*p2;int num;char name20;coutnum;if(!cin)throw string(數(shù)據(jù)輸入錯誤);if( !find(&p,num,name) )couttt找不到你要刪除的內(nèi)容!endl;return;couta;if(a=y|a=Y) p2=p-next;p-next=p2-next;delete p2;Bus_link:setkey(1);elsecoutntt對不起,游客

13、不能刪除車票信息endl;void Bus_link:mend()if(password=1)Bus_infor *p;int num;char name20;coutnum;if(!cin)throw string(數(shù)據(jù)輸入錯誤);if( !find(&p,num,name) )couttt找不到你要修改的內(nèi)容!next)-input();Bus_link:setkey(1);elsecoutntt對不起,游客不能修改車票信息endl;void Bus_link:Order()if(password=1)Bus_infor *p;coutX;if(X=y|X=Y)int num;coutnu

14、m;if(!cin)throw string(數(shù)據(jù)輸入錯誤);if( !find(&p,num,) )coutntt找不到你要定票的車輛的內(nèi)容!next;if(!(p-GetTime()/判斷要定票的車輛是否已經(jīng)出發(fā),若已經(jīng)出發(fā)則不允許定票coutntt你要訂票的車輛已出發(fā)!endl;return;coutn;if(!cin)throw string(數(shù)據(jù)輸入錯誤);if(p-Get_tickted()+n)Get_all_tickted()p-Order_tickt(n);else coutntt對不起,沒有足夠的票數(shù)。endl;else if(X=n|X=N) cout謝謝使用endl;e

15、lse coutnttt輸入字符不確定endl;Bus_link:setkey(1);elsecoutntt對不起,訂購車票請在管理員處購買endl;void Bus_link:Unorder()if(password=1)Bus_infor *p;coutX;if(X=y|X=Y)int num;coutnum;if(!cin)throw string(數(shù)據(jù)輸入錯誤);if( !find(&p,num,) )coutntt找不到你要退票的車輛的內(nèi)容!GetTime()/判斷要定票的車輛是否已經(jīng)出發(fā),若已經(jīng)出發(fā)則不允許定票coutntt你要退票的車輛已出發(fā)!endl;return;coutn;

16、if(!cin)throw string(數(shù)據(jù)輸入錯誤);p=p-next;if(p-Get_tickted()-n)=0)p-Unorder_tickt(n);else coutnttt對不起,數(shù)據(jù)出錯!。endl;else if(X=n|X=N) cout謝謝使用endl;else coutnttt輸入字符不確定endl;Bus_link:setkey(1);elsecoutntt對不起,退還車票請在管理員處退還next)(p-next)-output(os);p=p-next;coutttt文件已保存! endl;Bus_link:setkey(0);elsecoutntt對不起,游客無

17、法保存車票信息endl;void Bus_link:about()coutendl關(guān)于車票管理系統(tǒng)endlendl;cout使用說明:endlt1.請按照操作提示輸入正確的格式,以保證系統(tǒng)正常運行;endlt2.當(dāng)使用管理員登陸時,需輸入密碼,可進(jìn)行對系統(tǒng)的所有操作;endlt3.當(dāng)使用游客身份登陸時,無需輸入密碼,但只能瀏覽和查詢車票信息;endlt4.車票信息用文本文檔格式,保存在本程序文件夾目錄下,可以直接打開查看.endlendl系統(tǒng)說明:endlt本系統(tǒng)為課程設(shè)計作品,可以簡易的進(jìn)行車票管理,歡迎提出意見和建議endl t漳州師范學(xué)院計算機科學(xué)與工程系09非師四班t endlnum;

18、is.seekg(t);/移動到原來位置if(numinput(is);/輸入is對象內(nèi)容p-next=p2;p2-next=NULL;p=p-next;void Bus_link:clear()Bus_infor *p,*p2;p=head-next;while( p )p2=p;p=p-next;delete p2;char Bus_link:mainmenu()struct tm *local; char s1128;time_t t;t=time(NULL);local=localtime(&t);strftime(s1,128,%Y-%m-%d %H:%M ,local);/按照指定

19、的格式,把時間保存在s1字符串里面string s;/定義字符串s,來判斷功能選擇是否輸入錯誤coutnn 歡迎使用車票管理系統(tǒng)endlendl;cout endl endl 1. 錄入車票信息 2. 瀏覽車票信息 endl 3. 查詢車票信息 4. 刪除車票信息 endl 5. 修改車票信息 6. 定購車票信息 endl 7. 退還車票信息 8. 保存車票信息 endl 9. 關(guān)于車票系統(tǒng) 0. 退出系統(tǒng) endl endl endltttt s1endlendl;while(password=0)coutn;if(!cin)throw string(數(shù)據(jù)輸入錯誤);if(n=1)coutm;if(m=123456)password=1;coutendl;break;elsecoutntt密碼輸入不正確nendl;elsepassword=2;/游客身份標(biāo)志break;couts;if(s.length()!=1|s09) /s.length()返回字符串的長度,即字符個數(shù)cout輸入錯誤,請重新選擇功能按鈕: ;elsebreak;return s0

溫馨提示

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

最新文檔

評論

0/150

提交評論