C程序做的图书馆管理系统_第1页
C程序做的图书馆管理系统_第2页
C程序做的图书馆管理系统_第3页
C程序做的图书馆管理系统_第4页
C程序做的图书馆管理系统_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#include<iostream>#include<string>#include<ctime>#include<fstream>constinti=1000;intm=0,_m=0;usingnamespacestd;classlibrary;/************************时间类*******************************/classTime{private:intyear;intmonth;intDay;public:Time(){inttemp=time(0);intday1,day;year=1970+(temp-10*24*3600)/(3600*24*365);day=(temp-(year-1970)*(3600*24*365)-10*24*3600)/(3600*24)+1;if(0<day&&day<=31)month=1,day1=1;if(31<day&&day<=59)month=2,day1=31;if(59<day&&day<=90)month=3,day1=59;if(90<day&&day<=120)month=4,day1=90;if(120<day&&day<=151)month=5,day1=120;if(151<day&&day<=181)month=6,day1=151;if(181<day&&day<=212)month=7,day1=181;if(212<day&&day<=243)month=8,day1=212;if(243<day&&day<=273)month=9,day1=243;if(273<day&&day<=304)month=10,day1=273;if(304<day&&day<=334)month=11,day1=304;if(334<day&&day<=365)month=12,day1=334;Day=day-day1;};intgetyear(){returnyear;}intgetmonth(){returnmonth;}intgetDay(){returnDay;}};/************************************************书籍**************************************************/classbook{private:stringbookname[i];stringwriter[i];stringisbn[i];stringpress[i];stringedition[i];stringpublishing_time[i];stringcollection_number[i];intnumber[i];intbook_number;friendclasslibrary;public:voidadd_book(){stringBookname;stringWriter;stringIsbn;stringPress;stringEdition;stringPublishing_time;stringCollection_number;ofstreamout("book.txt",ios::app);cout<<"你要添加多少书籍"<<endl;cin>>book_number;cout<<"请输入书籍旳信息:(依次为书籍名称、作者、书号、出版社、版次、出版时间、馆藏编号)"<<endl;for(intn=0;n<book_number;n++){cout<<"书籍名称:";cin>>Bookname;cout<<"作者:";cin>>Writer;cout<<"书号:";cin>>Isbn;cout<<"出版社:";cin>>Press;cout<<"版次:";cin>>Edition;cout<<"出版时间:";cin>>Publishing_time;cout<<"馆藏编号:";cin>>Collection_number;out<<endl<<Bookname<<"\t"<<Writer<<"\t"<<Isbn<<"\t"<<Press<<"\t"<<Edition<<"\t"<<Publishing_time<<"\t"<<Collection_number<<"\t"<<"1";}out.close();}voidread_book(){m=0;ifstreamin("book.txt",ios::in);for(inta=0;!in.eof();a++){in>>bookname[a]>>writer[a]>>isbn[a]>>press[a]>>edition[a]>>publishing_time[a]>>collection_number[a]>>number[a];m++;}in.close();}voidjieshu(intn){read_book();ofstreamout("book.txt",ios::out);for(inta=0;a<m;a++){if(a==n)setnumber(a,0);out<<endl<<getbname(a)<<"\t"<<getwriter(a)<<"\t"<<getisbn(a)<<"\t"<<getpress(a)<<"\t"<<getedition(a)<<"\t"<<getpublishing_time(a)<<"\t"<<getcollection_number(a)<<"\t"<<getnumber(a);}out.close();}voidsetname(stringa,intn){bookname[n]=a;}voidsetwriter(stringa,intn){writer[n]=a;}voidsetisbn(stringa,intn){isbn[n]=a;}voidsetpress(stringa,intn){press[n]=a;}voidsetedition(stringa,intn){edition[n]=a;}voidsetpublishing_time(inta,intn){publishing_time[n]=a;}voidsetcollection_number(stringa,intn){collection_number[n]=a;}voidsetnumber(inti,inta){number[i]=a;}stringgetbname(inti){returnbookname[i];}stringgetwriter(inti){returnwriter[i];}stringgetisbn(inti){returnisbn[i];}stringgetpress(inti){returnpress[i];}stringgetedition(inti){returnedition[i];}stringgetpublishing_time(inti){returnpublishing_time[i];}stringgetcollection_number(inti){returncollection_number[i];}intgetnumber(inti){returnnumber[i];}voidshow(){for(inta=0;a<m;a++){cout<<bookname[a]<<""<<writer[a]<<""<<isbn[a]<<""<<press[a]<<""<<edition[a]<<""<<publishing_time[a]<<""<<collection_number[a]<<"";if(number[a]==1)cout<<"在架"<<endl;elsecout<<"借出"<<endl;}}};/********************************读者************************************/classreader{private:stringname[i];stringreadid[i];stringdepartment[i];charsort[i];intborrowbook[i];intydbook[i];intb_name[i][6];inty_name[i][3];public:voidREG(){///////////////注册intcount=-1;stringName;stringReadid;stringDepartment;charSort;ofstreamout("read.txt",ios::app);cout<<"请输入你旳信息:"<<endl;cout<<"姓名:";cin>>Name;cout<<"借书证号:";cin>>Readid;cout<<"系部:";cin>>Department;cout<<"学生?老师(s/学生,t/老师)";cin>>Sort;read_reader();for(inta=0;a<_m;a++){if(name[a]==Name){cout<<"该顾客名已被注册!"<<endl;count=a;break;}}//out.close();if(count==-1){cout<<"注册成功"<<endl;out<<endl<<Name<<"\t"<<Readid<<"\t"<<Department<<"\t"<<Sort<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0"<<"\t"<<"0";}}voidread_reader(){_m=0;ifstreamin("read.txt",ios::in);for(inta=0;!in.eof();a++){in>>name[a]>>readid[a]>>department[a]>>sort[a]>>borrowbook[a]>>ydbook[a]>>b_name[a][0]>>b_name[a][1]>>b_name[a][2]>>b_name[a][3]>>b_name[a][4]>>b_name[a][5]>>y_name[a][0]>>y_name[a][1]>>y_name[a][2];_m++;}in.close();}stringgetname(inta){returnname[a];}stringgetreadid(inta){returnreadid[a];}stringgetdepartment(inta){returndepartment[a];}chargetsort(inta){returnsort[a];}intgetybbook(inta){returnydbook[a];}intgetYname(inta,int_a){returny_name[a][_a];}intgetb_name(inta,intb){returnb_name[a][b];}intgetborrowbook(inta){returnborrowbook[a];}voidsetborrow(inta,int_a){borrowbook[a]=_a;}intgetydbook(inta){returnydbook[a];}intgety_name(inta,int_a){returny_name[a][_a];}voidsetb_name(inta,intb,intc){b_name[a][b]=c;}voidshow(){read_reader();for(inta=0;a<_m;a++){cout<<getname(a)<<""<<getreadid(a)<<""<<getdepartment(a)<<""<<getsort(a)<<""<<borrowbook[a]<<""<<ydbook[a]<<"";for(int_a=0;_a<6;_a++)cout<<b_name[a][_a]<<"";for(intA=0;A<3;A++)cout<<y_name[a][A]<<"";cout<<endl;}}};/***************************图书馆*******************************/classlibrary{public:stringBookname;stringWriter;stringIsbn;stringPress;stringEdition;intPublishing_time;stringCollection_number;intNumber;booka;intpd;readerb;intj;//记住登入人旳位置int_j;//记录书得位置voidsetj(inta){j=a;}intgetj(){returnj;}voidset_j(inta){_j=a;}intget_j(){return_j;}voidfind_name(ints){a.read_book();intcount=-1;cout<<"请输入书名:";cin>>Bookname;for(intn=0;n<m;n++){if(Bookname==a.getbname(n)){count=n;break;}}if(count==-1){cout<<"您要借阅旳书籍本馆暂无"<<endl<<endl<<"请重新选择"<<endl;if(s==1)find_book_interface();elseborrow_book_interface();}else{cout<<"书名:"<<a.getbname(count)<<endl;cout<<"作者;"<<a.getwriter(count)<<endl;cout<<"书号:"<<a.getisbn(count)<<endl;cout<<"出版社:"<<a.getpress(count)<<endl;cout<<"馆藏编号:"<<a.getcollection_number(count)<<endl;if(s==0){cout<<"确借阅本书?(y/n)";chars;cin>>s;if(s=='y'){if(a.getnumber(count)==1){cout<<"借阅成功!"<<endl;set_j(count);a.jieshu(count);borrow_book();}elsecout<<"本书已借出!"<<endl;}borrow_book_interface();}if(s==1)find_book_interface();}}voidfind_press(ints){a.read_book();intcount=-1;cout<<"请输入书籍出版社:";cin>>Press;for(intn=0;n<m;n++){if(Press==a.getpress(n))count=n;break;}if(count==-1){cout<<"您要借阅旳书籍本馆暂无"<<endl<<"请重新选择"<<endl;if(s==1)find_book_interface();elseborrow_book_interface();}else{cout<<"书名:"<<a.getbname(count)<<endl;cout<<"作者;"<<a.getwriter(count)<<endl;cout<<"书号:"<<a.getisbn(count)<<endl;cout<<"出版社:"<<a.getpress(count)<<endl;cout<<"馆藏编号:"<<a.getcollection_number(count)<<endl;if(s==0){cout<<"确借阅本书?(y/n)";chars;cin>>s;if(s=='y'){if(a.getnumber(count)==1){cout<<"借阅成功!"<<endl;a.jieshu(count);set_j(count);}elsecout<<"本书已借出!"<<endl;}borrow_book_interface();}if(s==1)find_book_interface();}}voidfind_isbn(ints){a.read_book();intcount=-1;cout<<"请输入书号:";cin>>Isbn;for(intn=0;n<m;n++){if(Isbn==a.getisbn(n))count=n;break;}if(count==-1){cout<<"您要借阅旳书籍本馆暂无"<<endl<<"请重新选择"<<endl;if(s==1)find_book_interface();elseborrow_book_interface();}else{cout<<"书名:"<<a.getbname(count)<<endl;cout<<"作者;"<<a.getwriter(count)<<endl;cout<<"书号:"<<a.getisbn(count)<<endl;cout<<"出版社:"<<a.getpress(count)<<endl;cout<<"馆藏编号:"<<a.getcollection_number(count)<<endl;if(s==0){cout<<"确借阅本书?(y/n)";chars;cin>>s;if(s=='y'){if(a.getnumber(count)==1){cout<<"借阅成功!"<<endl;a.jieshu(count);set_j(count);borrow_book();}elsecout<<"本书已借出!"<<endl;}borrow_book_interface();}if(s==1)find_book_interface();}}voidfind_collection_number(ints){a.read_book();intcount=-1;cout<<"请输入书籍馆藏编号:";cin>>Collection_number;for(intn=0;n<m;n++){if(Collection_number==a.getcollection_number(n))count=n;break;}if(count==-1){cout<<"您要借阅旳书籍本馆暂无"<<endl<<"请重新选择"<<endl;if(s==1)find_book_interface();elseborrow_book_interface();}else{cout<<"书名:"<<a.getbname(count)<<endl;cout<<"作者;"<<a.getwriter(count)<<endl;cout<<"书号:"<<a.getisbn(count)<<endl;cout<<"出版社:"<<a.getpress(count)<<endl;cout<<"馆藏编号:"<<a.getcollection_number(count)<<endl;if(s==0){cout<<"确借阅本书?(y/n)";chars;cin>>s;if(s=='y'){if(a.getnumber(count)==1){cout<<"借阅成功!"<<endl;a.jieshu(count);set_j(count);}elsecout<<"本书已借出!"<<endl;}borrow_book_interface();}if(s==1)find_book_interface();}}voidlibrary_interface(){////图书馆界面intc;cout<<"########################################"<<endl;cout<<"欢迎来到长沙学院图书馆"<<endl;cout<<"请按键选择功能"<<endl;cout<<"########################################"<<endl;cout<<"1、登陆2、顾客注册"<<endl;cout<<"3、图书管理 4、图书检索"<<endl;cout<<"5、退出系统"<<endl;cout<<"#########################################"<<endl;cin>>c;switch(c){case5:break;case4:find_book_interface();break;case3:book_manage();break;case2:b.REG();library_interface();break;case1:landing();break;default:break;}}voidyuding(){a.read_book();stringname;cout<<"请输入预订书籍名称:";cin>>name;intq=-1;for(intn=0;n<_m;n++){if(name==a.getbname(n)){q=n;if(a.getnumber(q)==0)cout<<"预订成功!"<<endl;elsecout<<"本书尚在馆内,无需预订!"<<endl;break;}}if(q==-1)cout<<"你预订旳书籍本馆暂无"<<endl;}voidlanding_interface(){///////登陆之后旳界面inta;cout<<"########################################"<<endl;cout<<"欢迎来到长沙学院图书馆"<<endl;cout<<"请按键选择功能"<<endl;cout<<"########################################"<<endl;cout<<"1、借书2.还书"<<endl;cout<<"3、图书检索4、图书预定"<<endl;cout<<"5.注销"<<endl;cout<<"#########################################"<<endl;cin>>a;switch(a){case1:borrow_book_interface();break;case2:break;case3:find_book_interface();break;case4:yuding();landing_interface();break;case5:library_interface();break;}}voidborrow_book(){////////////借书b.read_reader();a.read_book();stringc;int_c;_c=b.getborrowbook(get_j());_c++;ofstreamout("read.txt",ios::out);for(inta=0;a<_m;a++){if(a==getj()){b.setborrow(a,_c);b.setb_name(a,_c-1,get_j());}out<<endl<<b.getname(a)<<"\t"<<b.getreadid(a)<<"\t"<<b.getdepartment(a)<<"\t"<<b.getsort(a)<<"\t"<<b.getborrowbook(a)<<"\t"<<b.getydbook(a)<<"\t"<<b.getb_name(a,0)<<"\t"<<b.getb_name(a,1)<<"\t"<<b.getb_name(a,2)<<"\t"<<b.getb_name(a,3)<<"\t"<<b.getb_name(a,4)<<"\t"<<b.getb_name(a,5)<<"\t"<<b.gety_name(a,0)<<"\t"<<b.gety_name(a,1)<<"\t"<<b.gety_name(a,2);}}void_returnbook(){};voidlanding(){////////////////登陆stringname,id;b.read_reader();intcount=-1;cout<<"请输入名字:";cin>>name;cout<<"借书证号:";cin>>id;for(intn=0;n<_m;n++){if(b.getname(n)==name)if(b.getreadid(n)==id){cout<<"登陆成功!"<<endl;count=n;setj(count);landing_interface();}else{cout<<"借书证号错误!请重新输入"<<endl;landing();}cout<<n<<endl;}if(count==-1){cout<<"该账号尚未注册:"<<endl;library_interface();}}voidbook_manage(){////////////图书管理a.read_book();cout<<"1、添加书籍"<<endl;cout<<"2、显示所有书籍"<<endl;cout<<"3、返回主菜单"<<endl;cout<<"--------------"<<endl;cout<<"请选择"<<endl;intc;cin>>c;switch(c){case2:a.show();book_manage();

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论