C++實(shí)現(xiàn)圖書館管理系統(tǒng)_第1頁(yè)
C++實(shí)現(xiàn)圖書館管理系統(tǒng)_第2頁(yè)
C++實(shí)現(xiàn)圖書館管理系統(tǒng)_第3頁(yè)
C++實(shí)現(xiàn)圖書館管理系統(tǒng)_第4頁(yè)
C++實(shí)現(xiàn)圖書館管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩7頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

第C++實(shí)現(xiàn)圖書館管理系統(tǒng)Book(){borrow_flag=false;}

//無參構(gòu)造函數(shù)

Book(stringname,stringnum,stringauther)

:name(name),num(num),auther(auther){

borrow_flag=false;

}

//有參構(gòu)造函數(shù)

voidsetReader(stringreader,intlcn,stringdata);//設(shè)置讀者

voidsetInfo(stringname,stringnum,stringauther);//設(shè)置書籍信息

stringgetName(){

returnname;

}

stringgetNum(){returnnum;}

stringgetAuther(){

returnauther;

}

boolgetBorrow_flag(){

returnborrow_flag;

}

stringgetReader(){

returnreader;

}

intgetLcn(){

returnlcn;

}

stringgetData(){

returndata;

}

boolisBorrow(){returnborrow_flag;}

//判斷書籍是否借出

voidsetBorrow_flag(boolb){borrow_flag=b;}

voidshowInfo();

//顯示數(shù)據(jù)信息

private:

stringname;

//書名

stringnum;

//編號(hào)(唯一標(biāo)示)

stringauther;//作者

boolborrow_flag;

stringreader;//讀者

intlcn;

//借書證號(hào)

stringdata;

//借書日期

//DVD電影類

classDVD:publicMovie

//藍(lán)光電影類

classBlue_ligh:publicMovie

classPerson

public:

stringName;

stringAdress;

listitemRegist_items;

voidBook::setReader(stringreader,intlcn,stringdata)

borrow_flag=true;

this-reader.assign(reader);

this-lcn=lcn;

this-data.assign(data);

voidBook::setInfo(stringname,stringnum,stringauther)

this-name.assign(name);

this-num.assign(num);

this-auther.assign(auther);

voidBook::showInfo()

cout"書籍名稱:"setiosflags(ios_base::left)setw(56)nameendl

"書籍編號(hào):"setw(56)numendl

"書籍作者:"setw(56)auther

endl;

if(borrow_flag)

{

cout"書籍被借出。

\n"

"讀者姓名:"setw(56)readerendl

"借書證號(hào):"setw(56)lcnendl

"借書日期:"setw(56)dataendl;

}

else{

cout"書籍未被借出。

\n";

}

classLibrary

public:

//書籍庫(kù)

listitemitemList;

Library(){currentNum=0;brrowNum=0;}

voidaddBook();

//向圖書館里加書籍

voidaddBook(stringname,stringnum,stringauther);

voiddeleteBook();

//刪除無用書籍

voidbrrowBook();

//借書,之前先判斷書籍是否存在

voidreturnBook();

//還書

voidgetReader();

//查詢某編號(hào)的書是誰借了

intindexOfNum(stringnum);//根據(jù)編號(hào)得到書在數(shù)組中的下標(biāo)

vectorBookgetBooks(){

returnbooks;

}

voidshowInfo();

intgetTotalBooks(){returncurrentNum+brrowNum;}

private:

vectorBookbooks;//所有書籍

mapstring,intreaders;

//存儲(chǔ)讀者及其所借的書籍?dāng)?shù)目

intcurrentNum;

//庫(kù)存書籍?dāng)?shù)目(不包括借出的)

intbrrowNum;

//借出書籍?dāng)?shù)目

voidLibrary::showInfo()

cout"

***************************所有圖書信息***************************\n\n";

for(inti=0;ibooks.size();i++)

{

cout"第"i+1"本書籍的信息。"endl;

books[i].showInfo();

}

system("pause");

system("cls");

intLibrary::indexOfNum(stringnum)

inti;

for(i=0;ibooks.size();i++)

{

if(books[i].getNum()==num)

returni;

}

return-1;

voidLibrary::addBook()

Bookb;

inttemp;

stringname,num,auther;

cout"

*****************************增加界面*****************************\n\n";

do{

cout"輸入書籍名稱,編號(hào),作者:";

cinnamenumauther;

b.setInfo(name,num,auther);

if(indexOfNum(num)==-1){

books.push_back(b);

currentNum++;

cout"\n添加成功。"endl;

cout"輸入1繼續(xù)增加,返回上一層輸入2:";

cintemp;

}

else{

cout"已存在該編號(hào)的書籍,添加失敗。"endl;

cout"輸入1繼續(xù)重新增加,返回上一層輸入2:";

cintemp;

}

}while(temp==1);

system("pause");

system("cls");

voidLibrary::addBook(stringname,stringnum,stringauther)

Bookb;

b.setInfo(name,num,auther);

books.push_back(b);

voidLibrary::deleteBook()

intindex,temp;

stringnum;

cout"

*****************************刪除界面*****************************\n\n";

do{

cout"輸入要?jiǎng)h除的書籍的編號(hào):";

cinnum;

index=indexOfNum(num);

if(index!=-1){

if(!books[index].getBorrow_flag()){

cout"刪除的書籍的信息:\n";

books[index].showInfo();

books.erase(books.begin()+index);

currentNum--;

cout"刪除成功。"endl;

cout"輸入1繼續(xù)繼續(xù)刪除,返回上一層輸入2:";

cintemp;

}

else{

cout"刪除失敗!書籍已經(jīng)被借出。"endl;

cout"輸入1繼續(xù)繼續(xù)刪除,返回上一層輸入2:";

cintemp;

}

}

else

{

cout"刪除失敗。未找到編號(hào)為"num"的書籍。\n";

cout"輸入1繼續(xù)繼續(xù)刪除,返回上一層輸入2:";

cintemp;

}

}while(temp==1);

system("pause");

system("cls");

voidLibrary::brrowBook()

stringnum;

intindex;

cout"

*****************************借閱界面*****************************\n\n";

cout"輸入要借閱的書籍的編號(hào):";

cinnum;

index=indexOfNum(num);

if(index!=-1){

if(books[index].isBorrow()){

cout"借閱失敗,書籍以及被借出。\n";

system("pause");

system("cls");

}

else

{

cout"要借的書籍的信息:\n";

books[index].showInfo();

stringreader,data;

intlcn;

cout"輸入讀者姓名,借書證號(hào),借書日期:";

cinreaderlcndata;

if(readers[reader]!=2){

books[index].setReader(reader,lcn,data);

cout"借書完成。\n";

currentNum--;

brrowNum++;

readers[reader]++;

system("pause");

system("cls");

}

else

{

cout"借書失敗,該讀者以借超過兩本書籍。\n";

system("pause");

system("cls");

}

}

}

else

{

cout"借書失敗。未找到編號(hào)為"num"的書籍.\n";

system("pause");

system("cls");

}

voidLibrary::returnBook()

stringnum;

cout"

*****************************還書界面*****************************\n\n";

cout"輸入要還的書籍的編號(hào):";

cinnum;

intindex;

index=indexOfNum(num);

if(index!=-1)

{

cout"要還的書籍的信息為:\n";

books[index].showInfo();

books[index].setBorrow_flag(false);

readers[books[index].getReader()]--;

cout"還書成功。\n";

system("pause");

system("cls");

}

else

{

cout"還書失敗,請(qǐng)檢查書籍編號(hào)是否輸入錯(cuò)誤!\n";

system("pause");

system("cls");

}

voidLibrary::getReader()

stringnum;

cout"

*****************************查詢界面*****************************\n\n";

cout"輸入要查找的書籍編號(hào):";

cinnum;

intindex;

index=indexOfNum(num);

if(index!=-1)

{

if(books[index].getBorrow_flag())

cout"讀者為:"books[index].getReader()endl;

else{

cout"無讀者。"endl;

}

system("pause");

system("cls");

}

else

{

cout"查詢失敗,請(qǐng)檢查書籍編號(hào)是否輸入錯(cuò)誤!\n";

system("pause");

system("cls");

}

Libraryl;

voidmenu()

inttemp;

while(1)

{

cout"___________________________圖書館管理系統(tǒng)____________________________\n";

cout"

┏━━━━━━━━━━━━━┓

\n";

cout"

┃[0]退出系統(tǒng)。

\n";

cout"

┃[1]增加圖書。

\n";

cout"

┃[2]刪除圖書。

\n";

cout"

┃[3]借閱圖書。

\n";

cout"

┃[4]歸還圖書。

\n";

cout"

┃[5]顯示圖書信息。

\n";

cout"

┃[6]查詢圖書。

\n";

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 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)論