程序設(shè)計(jì)-圖書(shū)管理系統(tǒng)_第1頁(yè)
程序設(shè)計(jì)-圖書(shū)管理系統(tǒng)_第2頁(yè)
程序設(shè)計(jì)-圖書(shū)管理系統(tǒng)_第3頁(yè)
程序設(shè)計(jì)-圖書(shū)管理系統(tǒng)_第4頁(yè)
程序設(shè)計(jì)-圖書(shū)管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩38頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、程序設(shè)計(jì)報(bào)告( 2014 / 2015 學(xué)年 第 一 學(xué)期)題 目:南郵圖書(shū)館管理系統(tǒng) 專 業(yè) 計(jì)算機(jī)科學(xué)與技術(shù) 組長(zhǎng) 學(xué)號(hào)姓名 B13040415 馮加成 組員 學(xué)號(hào)姓名 B13040405 楊雨虹 B13040425 秦浩程 B13040435 丁九勝 指 導(dǎo) 教 師 汪云云 指 導(dǎo) 單 位 計(jì)算機(jī)軟件教學(xué)中心 日 期 2014年 11月21 日 成員分工馮加成框架設(shè)計(jì),文件讀取寫(xiě)入,菜單楊雨虹添加,刪除秦浩程修改信息,排序,搜索丁九勝借書(shū),還書(shū)評(píng)分細(xì)則評(píng)分項(xiàng)優(yōu)秀良好中等差遵守機(jī)房規(guī)章制度上機(jī)時(shí)的表現(xiàn)學(xué)習(xí)態(tài)度程序準(zhǔn)備情況程序設(shè)計(jì)能力團(tuán)隊(duì)合作精神課題功能實(shí)現(xiàn)情況算法設(shè)計(jì)合理性用戶界面設(shè)計(jì)報(bào)告

2、書(shū)寫(xiě)認(rèn)真程度內(nèi)容詳實(shí)程度文字表達(dá)熟練程度回答問(wèn)題準(zhǔn)確度簡(jiǎn)短評(píng)語(yǔ) 教師簽名: 汪云云 2014 年 11 月 22 日評(píng)分等級(jí)備注評(píng)分等級(jí)共五種:優(yōu)秀、良好、中等、及格、不及格南郵圖書(shū)館管理系統(tǒng)課題內(nèi)容和要求該系統(tǒng)要求建立一個(gè)南郵圖書(shū)館管理系統(tǒng),并具有排序、查找、計(jì)算、顯示等功能。通過(guò)此課題,熟練掌握文件、數(shù)組、指針的各種操作,以及一些算法思想的應(yīng)用。一、 需求分析功能框架圖:圖書(shū)管理系統(tǒng)查詢圖書(shū)添加刪除修改借書(shū)還書(shū)借書(shū)信息退出程序(1)查詢圖書(shū):按書(shū)名搜索books.txt(2)添加:添加圖書(shū)到文件books.txt(3)刪除:刪除圖書(shū)到文件books.txt(4)修改:修改某本書(shū)的信息,保存

3、到books.txt(5)借書(shū):借書(shū),并修改books.txt和borrowedbooks.txt(6)還書(shū):還書(shū),并修改books.txt和borrowedbooks.txt(7)借書(shū)信息:讀取borrowedbooks.txt,顯示借的書(shū)及借書(shū)人和即將到期的書(shū)(8)退出程序二、 概要設(shè)計(jì)1) 主要結(jié)構(gòu)體:class Bookpublic:string id;string name;string adress;string classification;int num;string price;string In_date;long Back_date;string borrowername

4、;long borrowtime;int times;int state;public:void copy(Book &book);2) 主要函數(shù)流程圖:buffer和borrowedbookbuffer函數(shù):將文件讀取,以一個(gè)數(shù)組返回開(kāi)始讀取文件能否打開(kāi)申請(qǐng)空間,讀入數(shù)據(jù)返回空間首地址結(jié)束否是 借書(shū): 還書(shū):開(kāi)始Buffer能否找到還書(shū),修改數(shù)據(jù)保存,修改借書(shū)庫(kù)(borrowedbookupdate)結(jié)束遍歷搜索保存圖書(shū)數(shù)據(jù)庫(kù)(update)否是開(kāi)始Buffer能否找到借書(shū),修改數(shù)據(jù)保存,插入到借書(shū)庫(kù)(borrowedbookupdate)結(jié)束遍歷搜索保存圖書(shū)數(shù)據(jù)庫(kù)(update)否是 添加

5、: 刪除:開(kāi)始Buffer能否找到刪除書(shū),修改數(shù)據(jù)結(jié)束遍歷搜索保存圖書(shū)數(shù)據(jù)庫(kù)(update)否是開(kāi)始輸入信息能否找到寫(xiě)入數(shù)據(jù)庫(kù)(writeIn)結(jié)束搜索同名圖書(shū)是否 排序: 修改數(shù)據(jù):開(kāi)始Buffer能否找到修改數(shù)據(jù)結(jié)束遍歷搜索保存圖書(shū)數(shù)據(jù)庫(kù)(update)是否繼續(xù)修改否否是是開(kāi)始Buffer選擇排序結(jié)束保存圖書(shū)數(shù)據(jù)庫(kù)(update)三、 源程序代碼 1.book.h#include#includeusing namespace std;class Bookpublic:string id;string name;string adress;string classification;int

6、num;string price;string In_date;long Back_date;string borrowername;long borrowtime;int times;int state;public:void copy(Book &book);void Book:copy(Book &book)id=book.id;name=;adress=book.adress;classification=book.classification;num=book.num;price=book.price;In_date=book.In_date;Back_date=b

7、ook.Back_date;borrowername=book.borrowername;borrowtime=book.borrowtime;times=book.times;state=book.state;2.borrowed_return.h#include#include#include#include#includefile.husing namespace std;void borrowedDelete(string bookname,int m,string name);void borrowedInsert(Book b,int num,string name);void b

8、orrowBook();void returnBook();void borrowedDelete(string bookname,int m,string name)Book* b;int n;int i;int j;int k=0;b=borrowedbookbuffer(n); /for (i=0;in;i+)if(bipare(bookname)=0 & bipare(name)=0)k=1;bi.num=bi.num-m;if(bi.num=0)for (j=i;jn-1;j+)bj.copy(bj+1);n-;break;if(k=0)cout輸入信息錯(cuò)誤endl;return;b

9、orrowedbookupdate(b,n);/delete b;void borrowedInsert(Book b,int num,string name)ofstream outf(borrowedbooks.txt,ios:app);if(!outf)coutcannot open the fileendl;return ;outfb.id ; ;outfb.adress ;outfb.classification ;outfnum ;outfb.price ; time_t timeval; timeval=time(NULL); outftimeval ; ou

10、tftimeval+86400*14 ; /兩周到期outfname ;outfendl;outf.close();void borrowBook()string bookname;coutbookname;Book* b;int i;int m;int n;int k=0;string name;b=buffer(n); /for (i=0;in;i+)if(bipare(bookname)=0)cout借幾本?m;cout姓名:name;if(bi.numm)cout書(shū)不夠。endl;return ;bi.num=bi.num-m;bi.times=bi.times+m;if(bi.num

11、=0)bi.state=0;k=1;break;if(k=0)cout沒(méi)有該書(shū).endl;return ;update(b,n); /borrowedInsert(bi,m,name);delete b;sort(); /void returnBook()Book* b;int i;int n;int k=0;int m;string name;string bookname;b=buffer(n); /cout還的書(shū)名:bookname;for (i=0;in;i+)if(bipare(bookname)=0)k=1;cout姓名:name;cout還幾本?m;bi.num=bi.num+m

12、;if(k=0)cout沒(méi)有該書(shū).endl;return ;borrowedDelete(bookname,m,name);update(b,n);delete b;3.change_sort_search.h#ifndef CHANGE_SORT_SEARCH_H#define CHANGE_SORT_SEARCH_H#include#include#include#include#includefile.husing namespace std;bool search(string bookname);bool search();void sort();void menuDetails()

13、;void changeDetails();bool search(string bookname)/search函數(shù)重載Book* b;int i=0;int k=0;int n;b=buffer(n); /調(diào)用緩存函數(shù),將b指針指向緩存區(qū)for (i=0;in;i+)if(bipare(bookname)=0)view(bi); /找到后,輸出k=1;if(k=1)return true;elsecout沒(méi)有該書(shū).endl;return false;delete b;bool search() /search函數(shù)重載string bookname;cout輸入書(shū)名:bookname;Boo

14、k* b;int i=0;int k=0;int n;b=buffer(n); /調(diào)用緩存函數(shù),將b指針指向緩存區(qū)for (i=0;in;i+)if(bipare(bookname)=0)view(bi);k=1;if(k=1)return true;elsecout沒(méi)有該書(shū).endl;return false;delete b;void sort()Book* b;int i=0;int j=0;int index;int n;b=buffer(n); /調(diào)用緩存函數(shù),將b指針指向緩存區(qū)for(i=0;in-1;i+) /選擇排序法index=i;for(j=i+1;jn;j+)if(bin

15、dex.timesbj.times)index=j;if(index!=i)Book temp;temp.copy(bi);bi.copy(bindex);bindex.copy(temp);update(b,n);delete b;void menuDetails()coutendl;cout 修改哪一項(xiàng): endl;cout 1.索引號(hào) endl;cout 2.書(shū)名 endl;cout 3.館藏地 endl;cout 4.分類 endl;cout 5.數(shù)量 endl;cout 6.價(jià)格 endl;cout 7.入館時(shí)間 endl;cout 8.接觸次數(shù) endl;cout 9.是否可借 e

16、ndl;cout 0.完成 endl;coutendl;void changeDetails()Book * b;int n;int i;string x;int s;int k=0;string bookname;b=buffer(n);/調(diào)用緩存函數(shù),將b指針指向緩存區(qū)cout修改哪一本?name?bookname;for (i=0;in;i+)if(bipare(bookname)=0)k=1;view(bi);break;if(k=0)cout沒(méi)有該書(shū).endl;return ;do coutx;getchar();stringstream sin(x);if(!(sins)cout非

17、法輸入endl;continue;stringstream sin2;sin2s;if(sin2.str().compare(x)!=0)cout非法輸入bi.id;break;case 2:;break;case 3:cinbi.adress;break;case 4:cinbi.classification;break;case 5:cinbi.num;break;case 6:cinbi.price;break;case 7:cinbi.In_date;break;case 8:cinbi.times;break;case 9:cinbi.state;break;ca

18、se 0:break ;while(s!=0);view(bi); update(b,n); /保存delete b;#endif4.delete_add.h#include#include#include#include#includechange_sort_search.h#includefile.husing namespace std;void add_book();void deleteBook();void add_book()string name;Book newbook;coutnewbook.id;;name=;if(

19、search(name) /cout已存在該書(shū),添加失敗endl;return ;coutnewbook.adress;coutnewbook.classification;coutnewbook.num;coutnewbook.price;coutnewbook.In_date;newbook.times=0;newbook.state=1;writeIn(newbook); /cout添加成功endl;void deleteBook()Book* b;int n;int i;int j;int k=0;b=buffer(n);string bookname;cout輸入待刪除的書(shū):book

20、name;for (i=0;in;i+)if(bipare(bookname)=0)/ string s1; pare(s2)=0;k=1;for (j=i;jn-1;j+)bj.copy(bj+1); /n-;break;if(k=0)cout沒(méi)有該書(shū).endl;return ;update(b,n); /delete b;5.file.h#ifndef FILE_H#define FILE_H#include#include#include#include#includebook.husing namespace std;Book* borrowedbookbuffer(int &n);B

21、ook* buffer(int &n);void writeIn(Book &b);void update(Book *b,int n);void borrowedbookupdate(Book *b,int n);void borrowedbookupdate(Book *b,int n)int i;ofstream outf(borrowedbooks.txt);if(!outf)coutcannot open the fileendl;return ;for(i=0;in;i+)outfbi.id ; ;outfbi.adress ;outfbi.classific

22、ation ;outfbi.num ;outfbi.price ;outfbi.borrowtime ;outfbi.Back_date ;outfbi.borrowername ;outfendl;outf.close();void writeIn(Book &b)ofstream outf(books.txt,ios:app);if(!outf)coutcannot open the fileendl;return ;outfb.id ; ;outfb.adress ;outfb.classification ;outfb.num ;outfb.price ;outfb

23、.In_date ;outfb.times ;outfb.state ;outfendl;outf.close();void update(Book *b,int n)int i=0;ofstream outf(books.txt);if(!outf)coutcannot open the fileendl;return ;for(i=0;in;i+)outfbi.id ; ;outfbi.adress ;outfbi.classification ;outfbi.num ;outfbi.price ;outfbi.In_date ;outfbi.times ;outfb

24、i.state ;outfendl;outf.close();Book* borrowedbookbuffer(int &n)string s;n=0;int i=0;ifstream inf(borrowedbooks.txt); if(!inf)coutcannot open the files;n+;n=n/9;Book* b=new Bookn;inf.clear();inf.seekg(0,ios:beg);while(!inf.eof()&ibi.id;;infbi.adress;infbi.classification;infbi.num;infbi.pric

25、e;infbi.borrowtime;infbi.Back_date;infbi.borrowername;i+;return b;Book* buffer(int &n)string s;int i=0;ifstream inf(books.txt); if(!inf)coutcannot open the files;n+;n=n/9;Book* b=new Bookn;inf.clear();inf.seekg(0,ios:beg);while(!inf.eof()&ibi.id;;infbi.adress;infbi.classification;infbi.num

26、;infbi.price;infbi.In_date;infbi.times;infbi.state;i+;return b;#endif6.view.h#include#include#include#include#includefile.husing namespace std;void view(Book b);void outPutDirectory();void soonExpire();void borrowedview();void viewAll();void view(Book b)cout索引號(hào) : b.idendl;cout書(shū)名 : endl;cout館藏地

27、 : b.adressendl;cout分類 : b.classificationendl;cout數(shù)目 : b.numendl;cout價(jià)格 : b.priceendl;cout入庫(kù)時(shí)間 : b.In_dateendl;cout次數(shù) : b.timesendl;if(b.state)cout可/不可借: 可借endl;elsecout可/不可借: 不可借endl;coutendl;void outPutDirectory()Book *b;int n;int i;b=buffer(n);for(i=0;in;i+)coutid : bi.id ;coutname: ;cout

28、endl;delete b;void soonExpire()Book* b;int n=0;int i;int k=0;b=borrowedbookbuffer(n); time_t timeval; timeval=time(NULL); int threeDay=86400*3;for (i=0;in;i+)if(bi.Back_date)=(timeval+threeDay)k=1;cout索引號(hào) : bi.idendl;cout書(shū)名 : endl;cout館藏地 : bi.adressendl;cout分類 : bi.classificationendl;cout數(shù)目

29、: bi.numendl;cout價(jià)格 : bi.priceendl;cout借書(shū)日期 : ctime(&bi.borrowtime);cout到期時(shí)間 : ctime(&bi.Back_date);cout借書(shū)人 : bi.borrowernameendl;coutendl;if(k=0)cout沒(méi)有即將到期的書(shū)endl;void borrowedview()Book* b;int n=0;int i;b=borrowedbookbuffer(n);for (i=0;in;i+)cout索引號(hào) : bi.idendl;cout書(shū)名 : endl;cout館藏地 : bi.adr

30、essendl;cout分類 : bi.classificationendl;cout數(shù)目 : bi.numendl;cout價(jià)格 : bi.priceendl;cout借書(shū)日期 : ctime(&bi.borrowtime);cout到期時(shí)間 : ctime(&bi.Back_date);cout借書(shū)人 : bi.borrowernameendl;coutendl;void viewAll()Book* b;int i=0;int j=0;int n;b=buffer(n);for(i=0;in;i+)view(bi);coutendl;delete b;7.南郵圖書(shū)管理系統(tǒng).cpp#inc

31、lude#include#include#include#include#includeview.h#includedelete_add.h#includechange_sort_search.h#includeborrow_return.husing namespace std;class Book;void search_menu();void add_menu();void delete_menu();void return_menu();void change_menu();void borrowedBook_menu();void Menu();void search_menu()c

32、outendl;cout 1. 顯示圖書(shū)館所有圖書(shū) endl;cout 2. 查詢 endl;cout 0. 返回 endl;coutendl;string x;int s;docoutx;getchar();stringstream sin(x);if(!(sins)cout非法輸入endl;continue;stringstream sin2;sin2s;if(sin2.str().compare(x)!=0)cout非法輸入endl;continue;switch(s)case 1: viewAll();system(PAUSE);system(cls);coutendl;cout 1. 顯示圖書(shū)館所有圖書(shū) endl;cout 2. 查詢 endl;cout 0. 返回 endl;coutendl;break;case 2: search();system(PAUSE);system(cls);coutendl;cout 1. 顯示圖書(shū)館所有圖書(shū) endl;cout 2. 查詢 endl;cout 0. 返回 endl;coutendl;break;case 0: system(cls);Menu() ;default:cout非法輸入endl;break;while(s!=0);voi

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論