




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
第C++實現(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;
//編號(唯一標示)
stringauther;//作者
boolborrow_flag;
stringreader;//讀者
intlcn;
//借書證號
stringdata;
//借書日期
//DVD電影類
classDVD:publicMovie
//藍光電影類
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
"書籍編號:"setw(56)numendl
"書籍作者:"setw(56)auther
endl;
if(borrow_flag)
{
cout"書籍被借出。
\n"
"讀者姓名:"setw(56)readerendl
"借書證號:"setw(56)lcnendl
"借書日期:"setw(56)dataendl;
}
else{
cout"書籍未被借出。
\n";
}
classLibrary
public:
//書籍庫
listitemitemList;
Library(){currentNum=0;brrowNum=0;}
voidaddBook();
//向圖書館里加書籍
voidaddBook(stringname,stringnum,stringauther);
voiddeleteBook();
//刪除無用書籍
voidbrrowBook();
//借書,之前先判斷書籍是否存在
voidreturnBook();
//還書
voidgetReader();
//查詢某編號的書是誰借了
intindexOfNum(stringnum);//根據(jù)編號得到書在數(shù)組中的下標
vectorBookgetBooks(){
returnbooks;
}
voidshowInfo();
intgetTotalBooks(){returncurrentNum+brrowNum;}
private:
vectorBookbooks;//所有書籍
mapstring,intreaders;
//存儲讀者及其所借的書籍?dāng)?shù)目
intcurrentNum;
//庫存書籍?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"輸入書籍名稱,編號,作者:";
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"已存在該編號的書籍,添加失敗。"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"輸入要刪除的書籍的編號:";
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"刪除失敗。未找到編號為"num"的書籍。\n";
cout"輸入1繼續(xù)繼續(xù)刪除,返回上一層輸入2:";
cintemp;
}
}while(temp==1);
system("pause");
system("cls");
voidLibrary::brrowBook()
stringnum;
intindex;
cout"
*****************************借閱界面*****************************\n\n";
cout"輸入要借閱的書籍的編號:";
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"輸入讀者姓名,借書證號,借書日期:";
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"借書失敗。未找到編號為"num"的書籍.\n";
system("pause");
system("cls");
}
voidLibrary::returnBook()
stringnum;
cout"
*****************************還書界面*****************************\n\n";
cout"輸入要還的書籍的編號:";
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"還書失敗,請檢查書籍編號是否輸入錯誤!\n";
system("pause");
system("cls");
}
voidLibrary::getReader()
stringnum;
cout"
*****************************查詢界面*****************************\n\n";
cout"輸入要查找的書籍編號:";
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"查詢失敗,請檢查書籍編號是否輸入錯誤!\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等.壓縮文件請下載最新的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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 行政管理???025年全方位試題及答案
- 2025年護士執(zhí)業(yè)考試心理素質(zhì)試題及答案
- 藥品評估中的臨床證據(jù)應(yīng)用試題及答案
- 行政法與社會公眾參與試題及答案
- 醫(yī)學(xué)倫理與法律問題的試題及答案解析
- 護理素養(yǎng)提升課程建議試題及答案
- 行政法與社會公平的關(guān)系試題及答案
- 行政管理文化概論學(xué)習(xí)階段中的試題及答案
- 2025年執(zhí)業(yè)醫(yī)師考試呼吸系統(tǒng)疾病試題及答案
- 中醫(yī)內(nèi)科學(xué)-肺癰課件
- 2024年時事政治考點大全(173條)
- 施工場地治安保衛(wèi)管理計劃
- 6《夜間飛行的秘密》(課件)統(tǒng)編版語文四年級上冊
- 2024年秋季新人教版八年級上冊物理全冊教案(2024年新教材)
- 高支模專項施工方案(專家論證后)
- 解讀國有企業(yè)管理人員處分條例課件
- 火力發(fā)電廠汽輪機控制系統(tǒng)技術(shù)條件
- 2024年湖南衡陽八中直選生綜合能力測試物理試題打印版
- 公司注銷解除合同判決書
- 設(shè)備使用培訓(xùn)計劃方案
- 江蘇省南京市秦淮區(qū)2023-2024學(xué)年八年級下學(xué)期歷史期末測試卷
評論
0/150
提交評論