(完整word版)C++影碟出租系統(tǒng)課程設(shè)計(jì)源代碼_第1頁
(完整word版)C++影碟出租系統(tǒng)課程設(shè)計(jì)源代碼_第2頁
免費(fèi)預(yù)覽已結(jié)束,剩余17頁可下載查看

下載本文檔

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

文檔簡介

1、實(shí)用文檔 #ifndef VIDEO_H #defi ne VIDEO_H #in clude #in clude using n amespace std; /class video stri ng vidn ame; class video / 影碟類 friend ostream &operator(ostream &os,video &vi); friend class applicati on; public: director,stri ng star,i nt nu mber) Vn ame=v name; Coun try=co un try; Type

2、=type; Producer=producer; Director=director; Star=star; Number =nu mber; video:video(video &vi) Vn ame=vi.V name; Coun try=vi.Co un try; Type=vi.Type; Producer=vi.Producer; Director=vi.Director; Star=vi.Star; Number=vi.Number; ostream &operator(ostream &os,video *vi)video(stri ng=,stri n

3、g=,i nt=0,stri ng=,stri ng=,stri ng= video(video &vi); void in put(); =,in t=0); /private: stri ng Vn ame; / 碟片名稱 stri ng Coun try; / 國家 int Type; 類型 stri ng Producer; / 制片人 stri ng Director; / 導(dǎo)演 stri ng Star; / 主演明星 int Number; / 庫存量 video *n ext; , video:video(stri ng vn ame,stri ng coun try,

4、i nt type,stri ng producer,stri 實(shí)用文檔 I; os該影碟信息為:e ndl; os”名稱:”Vname” 國家:”CountryType=1)osType=2)osType=3)osType=4)osType=5)osType=6)os 其他” ose ndl; 庫存 Numbere return os; #en dif friend ostream & operator (ostream &os,c onst Customer &cu); friend class applicati on; friend class video;os

5、 e nd os制片人:”Producer” 導(dǎo)演:Director 主演:Star #ifndef CUSTOMER #defi ne CUSTOMER #in clude #in clude #i ncludevideo.h using n amespace std; /class Customer struct VideoI nfo string VideoName; int Begi nTime; int En dTime; ; stri ng Cn ame; class Customer /碟片信息 /影片名稱 /影片借閱日期 /影片歸還日期 / 顧客類 實(shí)用文檔 public: C

6、ustomer(stri ng=,stri ng=,i nt=O,i nt=O,stri ng=,i nt=O,i nt=O); / 構(gòu)造函數(shù) int Decli neMon ey(i nt ); bool Ren tVideo(stri ng ); bool Retur nVideo(stri ng ); /private: stri ng idPers on; stri ng Name; int LeftMo ney; int nCount; VideoI nfo Video10; Customer *n ext1; ; Customer:Customer(stri ng /扣取消費(fèi)額 /

7、出租影碟 /歸還影片 / 會員賬號 /會員姓名 /會員剩余金額 /所借碟片數(shù)量 /每個(gè)會員最多借 idpers on, stri ng n ame,i nt 10 張影碟 leftmon ey,i nt ncoun t,stri ng 實(shí)用文檔 vide on ame,i nt begi ntime,i nt en dtime) idPers on=idpers on; Name=n ame; LeftM on ey=leftm on ey; nCount=ncount; for(i nt i=0;i nCoun t;i+) Videoi.VideoName=vide on ame; Vide

8、oi.Begi nTime=begi ntime; Videoi.E ndTime=e ndtime; ostream & operator (ostream &os,c onst Customer *cu) os會員編號為:tidPerso n 會員姓名為: 費(fèi)余額為:tLeftMo neye ndl; for (int i=0;inCoun t;i+) os所借影片名為:tVideoi.VideoNamee ndl; os影片借閱日期為:tVideoi.Begi nTimee ndl; os影片歸還日期為:tVideoi.E ndTimee ndl; os -n; retu

9、rn os; #en dif #ifndef MENU_H #defi ne MENU_H #in clude using n amespace std; /class menutName會員剩余會 實(shí)用文檔 class menu / public: int showMai nMen u(); private: ; int men u:showMa inMenu () system(cls); cout select; while(select12) cout選擇錯誤,請重新選擇 1-12 select; return select; #en dif #ifndef APPLICATION #

10、defi ne APPLICATION_H #in clude #in clude #in clude #i ncludevideo.h #i ncludeCustomer.h #in cludeme nu .hcout| 1. 影碟租賃 |e ndl; cout| 2. 影碟歸還 |e ndl; cout| 3. 查看各類型影碟信息 |e ndl; cout| 4. 查詢碟片信息 |e ndl; cout| 5. 添加新影碟 |e ndl; cout| 6. 刪除碟片信息 |e ndl; cout| 7. 修改碟片信息 |e ndl; cout| 8. 查看會員信息 |e ndl; cout

11、| 9. 注冊會員 |e ndl; cout| 10. 注銷會員 |e ndl; cout| 11. 更新會員信息與充值 endl; cout| 12. 退出系統(tǒng) |e ndl; cout e ndl; 歡迎使用影碟出租系統(tǒng) cout| * *|e ndl; cout請選擇 1-12 : endl; 菜單類 e ndl; |e ndl; coutn ext; delete vid; vid=v; vid=0;數(shù)據(jù)輸出 數(shù)據(jù)保存到文件 影碟租賃 影碟歸還 查看各類型影碟信息 根據(jù)類型查找 查看實(shí)用文檔 while(c) c=c- n extl; delete cus; cus=c; / vid=

12、0; void applicati on :load() ifstream file; / 碟片信息 stri ng Vn ame; / 碟片名稱 stri ng Coun try; / 國家 int Type; / 類型 stri ng Producer; / 制片人 stri ng Director; / 導(dǎo)演 stri ng Star; / 主演明星 int Number=0; / file.ope n(video.txt,ios:i n); 庫存量 fileV nameCo un try TypeProducerDirectorStar Number; while(file.good(

13、) v=new video( Vn ame,Co un try,Type,Producer,Director,Star,Number); v-n ext=0; /碟片結(jié)點(diǎn)加入鏈表 if(vid) / 若已經(jīng)存在結(jié)點(diǎn) video *v2; v2=vid; while(v2- next) / 查找尾結(jié)點(diǎn) v2=v2_n ext; v2- next=v; / 連接 else / 若不存在結(jié)點(diǎn)(表空) vid=v; / 連接 file Vn ameCo un tryTypeProducerDirectorStarNumber; file.close(); ifstream filel; / 會員信息

14、Customer *c=cus; stri ng idPers on; / 會員賬號 stri ng Name; /會員姓名 int LeftMo ney; /會員剩余金額 int nCount; /所借碟片數(shù)量 Videolnfo Video10; /每個(gè)會員最多借 10 張影碟 filel.ope n(Customer.txt,ios:i n); 實(shí)用文檔 file1 idPers on NameLeftM oneynCount; for(i nt i=0;i nCoun t;i+) file1 Videoi.Begi nTime Videoi.E ndTime Videoi.VideoN

15、ame; while(file1.good() for(i nt i=0;in ext1=0; /顧客結(jié)點(diǎn)加入鏈表 if(cus) / 若已經(jīng)存在結(jié)點(diǎn) Customer *c2; c2=cus; while(c2- next1)/ 查找尾結(jié)點(diǎn) c2=c2- next1; c2- next 仁 c; / 連接 else / 若不存在結(jié)點(diǎn)(表空) cus=c; / 連接 file1 Videoi.Begi nTime Videoi.E ndTime Videoi.VideoName; file1.close(); void applicati on:save() ofstream file(vid

16、eo.txt,ios:out); ofstream file1(Customer.txt,ios:out); char c; cout n 是否保存數(shù)據(jù)?Y/N:; cin c; if(toupper(c)!=Y) return; video *v=vid; while(v) fileVn ameCo un tryTypeProducerDirectorStar Numbern ext; file.close(); Customer *cu=cus; 實(shí)用文檔 while(cu) file1idPers on NameLeftM on eynCoun tVideon ext1; file1.c

17、lose(); coutn 保存成功.n; void applicati on:Re nt() int nu mber; Customer *c1; c1=cus; cout請輸入會員姓名:Name=C name) break; else c1=c1- n ext1; if(c1!=NULL) coutc1; cout10-c1- nCou nt) cout 租賃數(shù)目超過限定值! c1-LeftMo ney) cout余額不足,請充值或減少影碟數(shù)! endl; if(n umber nCou nt&n umber*20LeftMo ney) c1- nCount=nu mber; fo

18、r(i nt i=0;i nu mber;i+) cout c1-Videoi.Begi nTime; cout c1-Videoi.VideoName; c1-LeftMo ney-=nu mber*20; couttt 租賃成功! e ndl; else cout未找到該會員,請先注冊! endl; 實(shí)用文檔 void applicati on:Retur n() int nu mber,time; Customer *c1; c1=cus; cout請輸入會員姓名:Name=C name) break; else c1=c1- n ext1; if(c1!=NULL) coutc1; C

19、ustomeri nfo(C name); coutnCoun t=c1- nCount-nu mber; for(i nt i=0;i nu mber;i+) cout c1-Videoi.VideoName; cout c1-Videoi.E ndTime; cout time; if(time%3=0) c1-LeftMo ney=c1-LeftM on ey+20-time/3; else c1-LeftMo ney=c1-LeftM on ey+20-time/3-1; couttt 扣費(fèi)成功! e ndl; couttt* 歸還成功 *n; else cout未找到該會員,請確認(rèn)!

20、 Type=Type) break; else v1=v1- n ext; if(v1!=NULL) coutv1; else cout未找到該類型的碟片! endl; 實(shí)用文檔 void applicati on:Checkall() int Type;char c; cout選擇要查找的碟片類型(1.喜劇 2.悲劇 3.科幻片 4.懸疑劇 5.歷史劇 6.驚悚片 7.其他): Type; search(Type); cout* 以上為類型所有碟片 *e ndl; cout是否繼續(xù)查找【Y/N】 ? c; if(toupper(c)=Y) Checkall(); return ; else

21、return ; system(pause); void application:Check(string vidname) video *v1; v1= vid; while(v1) if(v1-V n ame=vid name) break; else v1=v1- n ext; if(v1!=NULL) coutv1;實(shí)用文檔 else cout未找到該碟片! endl; void applicati on:Addvideo() system(cls); video *v,*v2; / 新結(jié)點(diǎn)指針 stri ng Vn ame; / 碟片名稱 stri ng Coun try; / 國家

22、 int Type=7; / 類型 stri ng Producer; / 制片人 stri ng Director;丿 7 導(dǎo)演 stri ng Star; 主演明星 int Number=0; char c; / 庫存量 coutn* 新增碟片信息 /輸入碟片信息 * n; cout輸入片名 cin Vn ame; coutV name=Vn ame) break; else v1=v1- n ext; if(v1!=NULL) cout該碟片已存在,是否修改該碟片信息(Y/N) c; if(toupper(c)=Y) cout該碟片信息為:endl; Check(Vname); cout

23、e ndl; Modifyvideo( Vn ame); return ; else return ; cout國家:;cin Country; cout Type; 實(shí)用文檔 coutProducer; coutDirector; cout主演:;cin Star; coutNumber; v=new video( Vn ame,Co un try,Type,Producer,Director,Star,Number); v-n ext=0; /碟片結(jié)點(diǎn)加入鏈表 if(vid) / v2=vid; while(v2- next) / v2=v2-n ext; v2-n ext=v; / el

24、se / vid=v; / save(); coutttt * cout c; if(toupper(c)=Y) 若已經(jīng)存在結(jié)點(diǎn) 查找尾結(jié)點(diǎn) 連接 若不存在結(jié)點(diǎn)(表空) 連接 添加成功 *nendl; (Y/N) V name=Vn ame) break; else v2=v1; v1=v1- n ext; /刪除結(jié)點(diǎn) if(v1!=NULL) 若找到結(jié)點(diǎn),則刪除 cout所要刪除的碟片信息如下:nendl; coutv1; cout c; if(toupper(c)!=Y) return; if(v 仁=vid) / 若要刪除的結(jié)點(diǎn)是第一個(gè)結(jié)點(diǎn) vid=v1- n ext; delete v

25、1; else /若要刪除的結(jié)點(diǎn)是后續(xù)結(jié)點(diǎn) v2-n ext=v1- n ext; delete v1; save(); else Addvideo(); return ; void applicati 實(shí)用文檔 couttt* 刪除成功 *n; cout是否繼續(xù)刪除(Y/N) c; if(toupper(c)=Y) Deletevideo(); return ; else return ; else / 未找到結(jié)點(diǎn) coutV n ame=vid name) break; else v1=v1- n ext; if(v1!=NULL) 若找到結(jié)點(diǎn) system(cls); cout所要修改的

26、碟片信息如下 :nendl; coutv1; do cout1.修改碟片名稱 2.修改國家 3.修改類型 4.修改制片人 cout 5. 修改導(dǎo)演 6.修改主演 7.修改庫存量 8. ne ndl; cout請選擇(1-8)要修改的信息n c; if(c!=8) cout v1-V name; break; case 2: cin v1-Co un try; break; case 3: cin v1-Type; break; case 4: cin v1-Producer; break; case 5: cin v1-Director; break; case 6: cin v1-Star;

27、 break; case 7: cin v1-Number;break; default: break; while(c!=8); coutt * 修改成功 *nendl; cout是否繼續(xù)修改(Y/N): c; if(toupper(c)=Y) cout vid name; coute ndl; Modifyvideo(vid name); return ; else return ;II . 5 退出修改 實(shí)用文檔 else / 未找到結(jié)點(diǎn) coutName=C name) break; else c1=c1- n ext1; if(c1!=NULL) coutc1; else cout未找到該會員! endl; void applicati on:Add() system(cls); Customer *c,*c2; / 新結(jié)點(diǎn)指針 stri ng idPers on; / stri ng Nam

溫馨提示

  • 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論