return date; }
int reader::getavaiday() {
return avai_days; }
int reader::setname(char *names) {
strcpy(name,names); return 0; }
int reader::setnum(int nums) {
num=nums; return 0; }
int reader::setgrade(char *grades) {
strcpy(grade,grades); return 0; }
int reader::setclas(char *classes) {
strcpy(clas,classes); return 0; }
int reader::setsex(char *sexs) {
strcpy(sex,sexs); return 0; }
int reader::setbook_name(char *book_names) {
strcpy(book_name,book_names); return 0; }
int reader::setdate(char *dates) {
strcpy(date,dates); return 0; }
int reader::setavaiday(int avaiday) {
avai_days=avaiday;
. . . .return 0; }
int page_title() {
system(\
cout<<\ cout<<\☆★☆ 欢迎来到图书管理系统 ☆★☆ *\\n \
cout<<\ return 0; }
book::book() {
system(\ reader read; menu:
page_title();
cout<<\★主菜单★ \ cout<<\
cout<<\借 书 * \ cout<<\还 书 * \ cout<<\书籍管理 * \ cout<<\读者管理 * \ cout<<\搜 索 * \ cout<<\退 出 * \ cout<<\ cout<<\请输入你的选择:\ switch(getch()) {
case'1':book_out();break; case'2':book_in();break; case'3':book1();break;
case'4':read.read1();break; case'5':seach();break; case'0':exit(0);break; default:system(\ page_title();
cout<<\错误,请再输入一遍! \ }
goto menu; }
int book::book1() {
system(\
. . . . page_title();
cout<<\☆管理☆\ cout<<\
cout<<\增加书籍 * \endl<< endl; cout<<\注销书籍 * \endl<< endl; cout<<\修改书籍 * \endl<< endl; cout<<\返 回 *\
cout<<\ cout<<\请输入你的选择:\ switch(getch()) {
case'1':book_add();break; case'2':book_del();break; case'3':book_mod();break; case'0':return_back();break; default:system(\
cout<<\错误,请再输入一遍!\\n\ }
return 0; }
int book::book_add() //定义增加书籍的函数 {
FILE *bfp; int i,n;
page_title();
cout<<\☆增加书籍☆\ cout<<\请输入书的信息<<<\ bfp=fopen(\ for(n=0;n fread(&books[n],sizeof(books[n]),1,bfp); if(books[n].id==0) break; } fclose(bfp); do { cout<<\请输入一个新的书号(书号从1001开始,但必须不同于已存在的书号):\ cin>>books[n].id; for(i=0;i if(books[n].id==books[i].id&&n!=i) { cout<<\这个书号已经存在. \ break; . . . . } } }while(books[n].id==books[i].id); cout<<\书名: \ cin>>books[n].name; cout<<\作者: \ cin>>books[n].writer; cout<<\价格: \ cin>>books[n].price; cout<<\总存量: \ cin>>books[n].total; cout<<\现存量: \ cin>>books[n].store; cout<<\出版社: \ cin>>books[n].publish; cout<<\出版时间: \ cin>>books[n].pub_time; cout<<\借书人: \ cin>>books[n].borrower; cout<<\借书者学号: \ cin>>books[n].borr_num; bfp=fopen(\ for(n=0;n fwrite(&books[n],sizeof(books[n]),1,bfp); fclose(bfp); cout<<\该书已经添加.\\n\ return 0; } int book::book_del() //定义删除书籍的函数 { FILE *bfp; int i,id,s; page_title(); cout<<\☆注销旧书☆\ if((bfp=fopen(\ { cout<<\无法打开文件. \ } for(i=0;i fread(&books[i],sizeof(books[i]),1,bfp); } fclose(bfp); cout<<\请输入书号: \ . . . . cin>>id; for(i=0,s=-1;i if(books[i].id==id) { cout<<\书名: \ cout<<\书号: \ cout<<\作者: \ cout<<\价格: \ cout<<\总存量: \ cout<<\现存量: \ cout<<\出版社: \ cout<<\出版时间: \ cout<<\读者: \ cout<<\读者学号: \ cout<<\ cout<<\请问是否确定注销此书(1为是,0为否): \ cin>>s; if(s==1) { for(;i else if(s==0) { return 0; } } } if(s==-1) { cout<<\该书不存在.\ } if((bfp=fopen(\ { cout<<\无法打开文件. \ } for(i=0;i fwrite(&books[i],sizeof(books[i]),1,bfp); } fclose(bfp); return 0; . . . .