C程序做的圖書館管理系統(tǒng)_第1頁
C程序做的圖書館管理系統(tǒng)_第2頁
C程序做的圖書館管理系統(tǒng)_第3頁
C程序做的圖書館管理系統(tǒng)_第4頁
C程序做的圖書館管理系統(tǒng)_第5頁
已閱讀5頁,還剩22頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

#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<<"學(xué)生?老師(s/學(xué)生,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<<"歡迎來到長沙學(xué)院圖書館"<<endl;cout<<"請按鍵選擇功能"<<endl;cout<<"########################################"<<endl;cout<<"1、登陸2、顧客注冊"<<endl;cout<<"3、圖書管理 4、圖書檢索"<<endl;cout<<"5、退出系統(tǒng)"<<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<<"請輸入預(yù)訂書籍名稱:";cin>>name;intq=-1;for(intn=0;n<_m;n++){if(name==a.getbname(n)){q=n;if(a.getnumber(q)==0)cout<<"預(yù)訂成功!"<<endl;elsecout<<"本書尚在館內(nèi),無需預(yù)訂!"<<endl;break;}}if(q==-1)cout<<"你預(yù)訂旳書籍本館暫無"<<endl;}voidlanding_interface(){///////登陸之后旳界面inta;cout<<"########################################"<<endl;cout<<"歡迎來到長沙學(xué)院圖書館"<<endl;cout<<"請按鍵選擇功能"<<endl;cout<<"########################################"<<endl;cout<<"1、借書2.還書"<<endl;cout<<"3、圖書檢索4、圖書預(yù)定"<<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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論