C++技术交底大全报告图书馆管理系统

上传人:yh****1 文档编号:126884329 上传时间:2020-03-28 格式:DOC 页数:14 大小:62KB
返回 下载 相关 举报
C++技术交底大全报告图书馆管理系统_第1页
第1页 / 共14页
C++技术交底大全报告图书馆管理系统_第2页
第2页 / 共14页
C++技术交底大全报告图书馆管理系统_第3页
第3页 / 共14页
C++技术交底大全报告图书馆管理系统_第4页
第4页 / 共14页
C++技术交底大全报告图书馆管理系统_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《C++技术交底大全报告图书馆管理系统》由会员分享,可在线阅读,更多相关《C++技术交底大全报告图书馆管理系统(14页珍藏版)》请在金锄头文库上搜索。

1、/图书室管理系统 #include #include #include using namespace std;const int Max_book=3000; /可保存图书数量的上限const int Max_reader=1000; /可保存读者数量的上限const int Max_bor_book=2; /读者借阅图书本数上限class Book /图书类private:int ID; /登录号int num; /设置书目编号 int flag; /设置删除标记 int onshelf; /判断图书是否再架 char bname50; /设置图书书名char w_name10; /设置作

2、者姓名public:Book()int getID()return ID; /获取登录号 int getnum() return num; /获取图书编号int getflag() return flag; /获取删除标记char *getbname() return bname; /获取图书书名char *getw_name() return w_name; /获取作者姓名void setbname(char na)strcpy(bname,na); /设置书名void setwname(char na)strcpy(w_name,na);/设置作者名字void Addbook(int ID

3、,int n,char *na,char*wname); /新增图书int borrowbook(); /借阅图书void retbook(); /归还图书void delbook() flag=1; /删除图书信息void show(); /输出图书信息;void Book:Addbook(int ID,int n,char *na,char *wname)/新增图书信息 flag=0;ID=ID;num=n;strcpy(bname,na);strcpy(w_name,wname);onshelf=1;int Book:borrowbook() /借阅图书if (onshelf=1)ons

4、helf=0;return 1;return 0;void Book:retbook() /归还图书onshelf=1;void Book:show() /输出图书详细信息cout 图书状态:(onshelf=1? 在架可借:本馆借出) 作者姓名:w_name 书 名 : bname endl;cout 图书编号: num 登录号IDendl; class Bookdata /图书数据类private: int book_total; /图书总共数目Book bookMax_book; /图书记录数组public:Bookdata(); int Addbook(int ID,int n,cha

5、r *na,char *wname);/新增图书Book *search_ID(int ID) /按登录号查找图书for (int i=0;i=book_total;i+)if (booki.getID()=ID&booki.getflag()=0)return &booki;return NULL;Book *search_bnum(int book_num) /按图书编号查找图书for (int i=0;i=book_total;i+)if (booki.getnum()=book_num&booki.getflag()=0)return &booki;return NULL;Book *

6、search_bname(char bname50)/按图书书名查找图书for(int i=0;i=book_total;i+)if(strcmp(booki.getbname(),bname)=0&booki.getflag()=0)return &booki;return NULL; Book *search_wname(char wname50)/按作者姓名查找图书for(int i=0;i=book_total;i+)if(strcmp(booki.getw_name(),wname)=0&booki.getflag()=0)return &booki;return NULL; /图书

7、数据管理void bookdata(); /图书数据管理void show(); /输出书籍信息Bookdata() /析构函数fstream file(book.txt,ios:out);for (int i=0;i=book_total;i+)if (booki.getflag()=0)file.write(char *)&booki,sizeof(booki);file.close(); Bookdata:Bookdata() /构造函数 Book b;book_total=-1;fstream file(book.txt,ios:in);while (1)file.read(char

8、*)&b,sizeof(b);if (!file) break;book_total+;bookbook_total=b;file.close(); int Bookdata:Addbook(int ID,int n,char *na,char *wname)/新增图书Book *p=search_bnum(n);if (NULL=p)book_total+;bookbook_total.Addbook( ID,n,na,wname);return 1;return 0;void Bookdata:show() for (int i=0;i=book_total;i+) if (booki.g

9、etflag()=0) booki.show(); coutendl; void Bookdata:bookdata() int choice;char wname10;int ID;char bname50;int book_num;Book *b;while (choice!=0) cout n * endl; cout n 图 书 管 理 endl; cout n 1 新增图书信息 endl; cout n 2 图书信息更改 endl; cout n 3 删除图书信息 endl; cout n 4 图书信息显示 endl; cout n 5 搜索图书信息 endl; cout n 0 安全退出模块 endl; cout n * endl; cout 请输入相对有的数字: choice;if(choice5)cout 对不起,输入有误,请查证后再输入! endl;else break;while(1);switch (choice)case 1:cout 请输入新增图书的书名: bname;cout 请输入新增图书的登录号: ID;cout 请输入新增图书作者姓名: wname;cout 请输入新增图书的编号: book_num;Addbook(ID,bo

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 建筑资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号