图书信息管理系统设计1

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

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

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

资源描述

#includeiostream#includestring.h#includefstreamusingnamespacestd;classcontrolloer//图书管理员{private:intnumber;intage;charname[20];public:controlloer();controlloer(intc,inta,charb[20]);intgetnumber();intgetage();char*getname();voidreworkage(inti);voidreworkname(chara[20]);};controlloer::controlloer(){number=0;charb[20]=noone;age=0;strcpy(name,b);}controlloer::controlloer(intc,inta,charb[20]){number=c;age=a;strcpy(name,b);}intcontrolloer::getage(){returnage;}char*controlloer::getname(){returnname;}intcontrolloer::getnumber(){returnnumber;}voidcontrolloer::reworkage(inti){age=i;}voidcontrolloer::reworkname(chara[20]){strcpy(name,a);}classreader//读者(学生,老师){private:intnumber;intage;charname[20];charzhiye[20];charborrowbook[20];public:reader();reader(intc,inta,charb[20],chard[20],chare[20]);intgetnumber();intgetage();char*getzhiye();char*getname();char*getborrowbook();voidreworkborrowbook(chara[20]);};reader::reader(){chara[20]=没有人;charb[20]=无职称;charc[20]=没有借书;number=0;age=0;strcpy(name,a);strcpy(zhiye,b);strcpy(borrowbook,c);}reader::reader(inta,intc,charb[20],chard[20],chare[20]){number=a;age=c;strcpy(name,b);strcpy(zhiye,d);strcpy(borrowbook,e);}intreader::getnumber(){returnnumber;}intreader::getage(){returnage;}char*reader::getzhiye(){returnzhiye;}char*reader::getname(){returnname;}char*reader::getborrowbook(){returnborrowbook;}voidreader::reworkborrowbook(chara[20]){strcpy(borrowbook,a);}structbook//图书{intnum;charname[20];charpeople[20];};voidstore()//存入图书信息{inti,c,b;chara[20],d[20];ifstreamfile(num.txt);fileb;file.close();cout现有的图书个数:;coutbendl;cout请输入你要输入的图书信息个数:endl;cinc;book*shu=newbook[c];cout输入图书信息(编号,名字,作者名:)endl;for(i=0;ic;i++){cinshu[i].num;cinad;strcpy(shu[i].name,a);strcpy(shu[i].people,d);b++;}ofstreamoutfile(stu.txt,ios_base::app);for(i=0;ic;i++){outfile.write((char*)&shu[i],sizeof(shu[i]));}outfile.close();cout存入成功!endl;ofstreamtfile(num.txt);tfileb;tfile.close();}voidoutbook()//输出图书信息{inti,h,j,g,z;chark;ifstreamtfile(num.txt);if(!tfile){cout文件不存在!;tfile.close();cout你是否想创建(输入Y或N);cink;if(k=='N')exit(0);else{ofstreamtfile(num.txt);g=0;tfileg;}}elsetfileg;cout本图书馆已经有g本图书endl;if(g==0){cout图书馆里没有书!endl;exit(0);}else{book*shu=newbook[g];ifstreamis(stu.txt,ios_base::binary);if(is){for(i=0;ig;i++){is.read((char*)&shu[i],sizeof(shu[i]));}for(i=0;ig;i++){cout编号名字作者名endl;coutshu[i].numshu[i].nameshu[i].peopleendl;}}else{coutERROR:cannotopenfile'stu.txt'endl;}is.close();ifstreamfile(readernum.txt);if(file){filez;file.close();}else{cout没有文件;}cout已有的读者个数:;coutzendl;cout输入你的编号:;cinj;cout你想借哪本书(输入编号):;cinh;reader*people=newreader[z];ifstreamout(reader.txt,ios_base::binary);if(out){for(i=0;iz;i++){out.read((char*)&people[i],sizeof(people[i]));}}else{coutERROR:cannotopenfile'stu.txt'endl;}out.close();people[j-1].reworkborrowbook(shu[h-1].name);cout编号年龄名字职业借书情况endl;coutpeople[j-1].getnumber()people[j-1].getage()people[j-1].getname()people[j-1].getzhiye()people[j-1].getborrowbook()endl;ofstreamoutfile(reader.txt,ios_base::binary);for(i=0;iz;i++){outfile.write((char*)&people[i],sizeof(people[i]));}outfile.close();}cout借阅成功!;}voidcontroller()//图书管理员信息{intb,i,d,h=0;ifstreamfile(controlloernum.txt);if(file){fileb;file.close();cout图书管理员个数:bendl;}else{cout没有图书管信息理员endl;cout你是否想创建(请输入Y或N):;cind;if(d='y'){ofstreaminfile(controlloernum.txt);infileh;exit(0);}elseexit(0);}ifstreamis(controlloer.txt,ios_base::binary);if(is){controlloer*bookpeople=newcontrolloer[b];for(i=0;ib;i++){is.read((char*)&bookpeople[i],sizeof(bookpeople[i]));}for(i=0;ib;i++){cout编号年龄名字endl;coutbookpeople[i].getnumber()bookpeople[i].getage()bookpeople[i].getname()endl;}}else{coutERROR:cannotopenfile'stu.txt'endl;cout没有这个文件夹endl;cout你是否想创建(请输入Y或N):;cind;if(d='y'){ofstreaminfile(controlloer.txt);exit(0);}elseexit(0);}is.close();}voidlibary()//图书馆的总信息{system(cls);system(color2e);coutendl;coutendl;coutendl;cout学校图书馆由本部图书馆及彭州校区图书馆组成.馆舍面积41048平方米;cout(其中现有馆舍面积11578平方米,在建图书馆馆舍面积29470平方米),;cout各院系资料室面积1120平方米。学校拥有纸质文献198万余册,;cout生均81.17册,电子文献161.7万余种。近三年校图书馆每年进书量均超过15万册.endl;}voidstorecontroller()//存入新的管理员的信息{inti,b,c,h=0;chara[20],d;ifstreamfile(controlloernum.txt);if(file){fileb;file.close();cout已有的图书管理员个数:;coutbendl;}else{cout没有图书管信息理员endl;cout你是否想创建(请输入y或n):;cind;if(d=='y'){ofstreaminfile(controlloernum.txt);infileh;infile.close();b=0;}elseexit(0);}ofstreamoutfile(controlloer.txt,ios::app);cout请输入图书管理员的编号和年龄,名字:;cincia;controlloerbookpeople(c,i,a);cout编号年龄名字endl;coutbookpeople.getnumber()bookpeople.getage()bookpeople.getname()endl;outfile.write((char*)&bookpeople,sizeof(bookpeople));outfile.close();b++;ofstreamtfile(controlloernum.txt);tfileb;tfile.close();cout保存成功!;}voidreworkcontrolloer()///修改图书管理员{inti,b,h,j,g;chard[20];ifstreamfile(controlloernum.txt);if(file){fileb;file.close();}else{cout没有图书管信息理员;exit(0);}

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

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

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

×
保存成功