《2023年C观影网站管理系统.pdf》由会员分享,可在线阅读,更多相关《2023年C观影网站管理系统.pdf(20页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、#include#include#include using namespace std;/第一部分:用户类 class user public:user()user(string name):name(name)user(string name,int level,int age,string occupation,string hobby,string email);string getusername()return name;void writeuser();friend istream&operator(istream&in,user&u);private:string name;i
2、nt level;int age;string occupation;string hobby;string email;user:user(string name,int level,int age,string occupation,string hobby,string email):name(name),age(age),occupation(occupation),hobby(hobby),email(email)ofstream outfile;outfile.open(userfile.txt,ios:app);outfilename level age occupation h
3、obby emailendl;outfile.close();void user:writeuser()ofstream outfile;outfile.open(userfile.txt,ios:app);coutname;coutlevel;coutage;coutoccupation;couthobby;coutemail;coutendl;outfilename level age occupation hobby email(istream&in,user&u)inu.name;return in;/*/第二部分:电影类 class movie public:movie()movie
4、(string name):name(name)movie(string name,int year,string direct,string role,string company,string grade);movie()void writemoive();string getmoviename()return name;friend istream&operator(istream&in,movie&m);friend class comment;private:string name;int year;string direct;string role;string company;s
5、tring grade;movie:movie(string name,int year,string direct,string role,string company,string grade):name(name),year(year),direct(direct),role(role),company(company),grade(grade)ofstream outfile;outfile.open(moviefile.txt,ios:app);outfilename year direct role company gradeendl;outfile.close();void mo
6、vie:writemoive()ofstream outfile;outfile.open(moviefile.txt,ios:app);coutname;coutyear;coutdirect;coutrole;coutcompany;coutgrade;coutendl;outfilename year direct role company grade(istream&in,movie&m)inm.name;return in;/*/第三部分:影评类 class comment public:comment(movie moviecomment);comment(movie moviec
7、omment,user usercomment,double score,string connection);comment()void writecomment(user rcomment);private:string username;string moviename;double score;string connection;static int commentcount;int comment:commentcount=0;comment:comment(movie moviecomment)commentcount+;moviename=moviecomment.getmovi
8、ename();coutconnection;comment:comment(movie moviecomment,user usercomment,double score,string connection):score(score),connection(connection)commentcount+;moviename=moviecomment.getmoviename();username=usercomment.getusername();ofstream outfile;outfile.open(commentfile.txt,ios:app);outfilemoviename
9、 username score connection commentcountendl;outfile.close();void comment:writecomment(user usercomment)username=usercomment.getusername();ofstream outfile;outfile.open(commentfile.txt,ios:app);coutscore;outfilemoviename username score connection commentcountendl;outfile.close();/*/第四部分:菜单系统功能函数编辑部分
10、void initialization()coutMenu system readyendl;movie Zootopia(Zootopia ,2016,Howard ,Jodie ,Disney,PG);movie Begonia(Begonia ,2016,LiangXuan,chun ,Enlight,PG);movie Doraemon(Doraemon ,2016,Shinosuke,Doraemon,Toho ,PG);void writenewuser()coutyou can add users infomation:endl;coutendl;user newuser;new
11、user.writeuser();void readuser()coutthis is users infomation:endl;coutendl;coutname level age occupation hobby emailendl;ifstream in(userfile.txt);char p;while(in.get(p)cout.put(p);void writenewmoive()movie newmovie;newmovie.writemoive();void readmovie()coutthis is movies infomation:endl;coutendl;co
12、utmoviename year direct role company gradeendl;ifstream in(moviefile.txt);char p;while(in.get(p)cout.put(p);void writenewcomment()coutyou can add movies infomation:endl;user commentuser;movie commentmovie;coutyou can add comments infomation:endl;coutcommentuser;coutcommentmovie;comment newcomment(co
13、mmentmovie);newcomment.writecomment(commentuser);void readcomment()coutthis is comments infomation:endl;coutmoviename username score connection commentcountendl;ifstream in(commentfile.txt);char p;while(in.get(p)cout.put(p);void clearing()coutMenu system clearingendl;ofstream outfile;outfile.open(us
14、erfile.txt);outfile.close();outfile.open(moviefile.txt);outfile.close();outfile.open(commentfile.txt);outfile.close();/*/第五部分,菜单系统实现部分 void menuframe()cout*endl;cout*Welcome to the movie critic information management system*endl;cout*endl;coutendl;cout-endl;cout enter 1 make menu system ready endl;c
15、out-endl;cout enter 2 look up users infomation endl;cout-endl;cout enter 3 increase users infomation endl;cout-endl;cout enter 4 look up moives infomation endl;cout-endl;cout enter 5 increase moives infomation endl;cout-endl;cout enter 6 look up comments infomaition endl;cout-endl;cout enter 7 incre
16、ase comments infomation endl;cout-endl;cout enter 8 make menu system clearing endl;cout-endl;cout enter 0 exit menu system endl;cout-endl;coutendl;coutendl;int menuinput()int order;coutorder;coutendl;return order;void menuimplementation(int order)switch(order)case 0:exit(0);break;case 1:initializati
17、on();break;case 2:readuser();break;case 3:writenewuser();break;case 4:readmovie();break;case 5:writenewmoive();break;case 6:readcomment();break;case 7:writenewcomment();break;case 8:clearing();break;default:coutyour input wrong,please re-enter the instruction!endl;break;/*/第六部分:主函数 int main()menuframe();while(true)cout*endl;int instruct=menuinput();menuimplementation(instruct);cout*endl;coutendl;coutendl;return 0;