C++影碟出租系统课程设计源代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#ifndefVIDEO_H#defineVIDEO_H#includeiostream#includestringusingnamespacestd;//classvideostringvidname;classvideo{//影碟类friendostream&operator(ostream&os,video&vi);friendclassapplication;public:video(string=,string=,int=0,string=,string=,string=,int=0);video(video&vi);voidinput();//private:stringVname;//碟片名称stringCountry;//国家intType;//类型stringProducer;//制片人stringDirector;//导演stringStar;//主演明星intNumber;//库存量video*next;};video::video(stringvname,stringcountry,inttype,stringproducer,stringdirector,stringstar,intnumber){Vname=vname;Country=country;Type=type;Producer=producer;Director=director;Star=star;Number=number;}video::video(video&vi){Vname=vi.Vname;Country=vi.Country;Type=vi.Type;Producer=vi.Producer;Director=vi.Director;Star=vi.Star;Number=vi.Number;}ostream&operator(ostream&os,video*vi){os****************************************************************endl;os该影碟信息为:endl;os名称:vi-Vname国家:vi-Country类型:;if(vi-Type==1)os喜剧;else{if(vi-Type==2)os悲剧;else{if(vi-Type==3)os科幻片;else{if(vi-Type==4)os悬疑剧;else{if(vi-Type==5)os惊悚片;else{if(vi-Type==6)os其他;}}}}}osendl;os制片人:vi-Producer导演:vi-Director主演:vi-Star库存量:vi-Numberendl;returnos;}#endif#ifndefCUSTOMER_H#defineCUSTOMER_H#includeiostream#includestring#includevideo.husingnamespacestd;//classCustomerstructVideoInfo{//碟片信息stringVideoName;//影片名称intBeginTime;//影片借阅日期intEndTime;//影片归还日期};stringCname;classCustomer{//顾客类friendostream&operator(ostream&os,constCustomer&cu);friendclassapplication;friendclassvideo;public:Customer(string=,string=,int=0,int=0,string=,int=0,int=0);//构造函数intDeclineMoney(int);//扣取消费额boolRentVideo(string);//出租影碟boolReturnVideo(string);//归还影片//private:stringidPerson;//会员账号stringName;//会员姓名intLeftMoney;//会员剩余金额intnCount;//所借碟片数量VideoInfoVideo[10];//每个会员最多借10张影碟Customer*next1;};Customer::Customer(stringidperson,stringname,intleftmoney,intncount,stringvideoname,intbegintime,intendtime){idPerson=idperson;Name=name;LeftMoney=leftmoney;nCount=ncount;for(inti=0;inCount;i++){Video[i].VideoName=videoname;Video[i].BeginTime=begintime;Video[i].EndTime=endtime;}}ostream&operator(ostream&os,constCustomer*cu){os会员编号为:\tcu-idPerson会员姓名为:\tcu-Name会员剩余会费余额为:\tcu-LeftMoneyendl;for(inti=0;icu-nCount;i++){os所借影片名为:\tcu-Video[i].VideoNameendl;os影片借阅日期为:\tcu-Video[i].BeginTimeendl;os影片归还日期为:\tcu-Video[i].EndTimeendl;os--------------------------------------------\n;}returnos;}#endif#ifndefMENU_H#defineMENU_H#includeiostreamusingnamespacestd;//classmenuclassmenu{//菜单类public:intshowMainMenu();private:};intmenu::showMainMenu(){system(cls);cout————————————————————————endl;cout|欢迎使用影碟出租系统|endl;cout|************************************************|endl;cout|1.影碟租赁|endl;cout|2.影碟归还|endl;cout|3.查看各类型影碟信息|endl;cout|4.查询碟片信息|endl;cout|5.添加新影碟|endl;cout|6.删除碟片信息|endl;cout|7.修改碟片信息|endl;cout|8.查看会员信息|endl;cout|9.注册会员|endl;cout|10.注销会员|endl;cout|11.更新会员信息与充值|endl;cout|12.退出系统|endl;cout————————————————————————endl;cout请选择1-12:endl;intselect;cinselect;while(select1||select12){cout选择错误,请重新选择1-12endl;cin.clear();//当输入字符,清空流错误状态cin.sync();//清空数据流cinselect;}returnselect;}#endif#ifndefAPPLICATION_H#defineAPPLICATION_H#includeiostream#includestring#includefstream#includevideo.h#includeCustomer.h#includemenu.husingnamespacestd;classapplication{//数据应用类public:application();~application();voidload();//数据输出voidsave();//数据保存到文件voidRent();//1.影碟租赁voidReturn();//2.影碟归还voidCheckall();//3.查看各类型影碟信息voidsearch(intType);//根据类型查找voidCheck(stringvidname);//4.查看影碟信息:根据碟片名称查找voidAddvideo();//5.添加影碟voidDeletevideo();//6.删除影碟voidModifyvideo(stringVname);//7.修改影碟信息voidCustomerinfo(stringCname);//8.会员信息:根据姓名查找voidAdd();//9.注册会员voidDelete();//10.注销会员voidModify(stringName);//11.更新会员信息与充值voidrun();private:stringtitle;menumyMenu;videomyvideo;Customermycustomer;video*vid;Customer*cus;};application::application(){vid=0;cus=0;load();}application::~application(){video*v;v=vid;Customer*c;c=cus;while(v){v=v-next;deletevid;vid=v;}vid=0;while(c){c=c-next1;deletecus;cus=c;}vid=0;}voidapplication::load(){ifstreamfile;//碟片信息video*v=vid;stringVname;//碟片名称stringCountry;//国家intType;//类型stringProducer;//制片人stringDirector;//导演stringStar;//主演明星intNumber=0;//库存量file.open(video.txt,ios::in);fileVnameCountryTypeProducerDirectorStarNumber;while(file.good()){v=newvideo(Vname,Country,Type,Producer,Director,Star,Number);v-next=0;//碟片结点加入链表if(vid)//若已经存在结点{video*v2;v2=vid;while(v2-next)//查找尾结点{v2=v2-next;}v2-next=v;//连接}else//若不存在结点(表空)vid=v;//连接fileVnameCountryTypeProducerDirectorStarNumber;}file.close();ifstreamfile1;//会员信息Customer*c=cus;stringidPerson;//会员账号stringName;//会员姓名intLeftMoney;//会员剩余金额intnCount;//所借碟片数量VideoInfoVideo[10];//每个会员最多借10张影碟file1.open(Customer.txt,ios::in);file1idPersonNameLeftMoneynCount;for(inti=0;inCount;i++){file1Video[i].BeginTimeVideo[i].EndTimeVideo[i].VideoName;}w

1 / 20
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功