图书管理系统实现代码c++语言Word格式.docx

上传人:b****6 文档编号:20021869 上传时间:2023-01-15 格式:DOCX 页数:26 大小:20.21KB
下载 相关 举报
图书管理系统实现代码c++语言Word格式.docx_第1页
第1页 / 共26页
图书管理系统实现代码c++语言Word格式.docx_第2页
第2页 / 共26页
图书管理系统实现代码c++语言Word格式.docx_第3页
第3页 / 共26页
图书管理系统实现代码c++语言Word格式.docx_第4页
第4页 / 共26页
图书管理系统实现代码c++语言Word格式.docx_第5页
第5页 / 共26页
点击查看更多>>
下载资源
资源描述

图书管理系统实现代码c++语言Word格式.docx

《图书管理系统实现代码c++语言Word格式.docx》由会员分享,可在线阅读,更多相关《图书管理系统实现代码c++语言Word格式.docx(26页珍藏版)》请在冰豆网上搜索。

图书管理系统实现代码c++语言Word格式.docx

books;

/*****************************************************声明一个存放Book类的向量,用于数据操作*/

intcount;

public:

Bookmanage(void);

voidaddBooks();

/********************************************************************************图书的添加函数*/

voidfindBook();

voidlendbook();

voidreturnbook();

voidchangbook();

/**************************************************************************修改书籍的相关信息*/

~Bookmanage(void);

};

/*******************************************************************************************************************

Book.h        

Book类的定义

 2012-4-02~2012-4-10

*******************************************************************************************************************/

iostream>

Book:

:

Book(stringnewname,stringnewnum,stringnewwri,stringnewpub,intstate)/*******************构造函数重载的定义*/

BookName=newname;

Booknum=newnum;

Writer=newwri;

Publisher=newpub;

Bookstate=state;

}

voidBook:

displayInfo()const

cout<

<

"

图书的名字是\t"

BookName<

endl;

图书的书号是\t"

Booknum<

图书的作者\t"

Writer<

图书的出版社\t"

Publisher<

if(Bookstate==0)

{

cout<

"

在馆"

<

endl;

}

else

{cout<

已借出"

}

cin.get();

setname(stringnewname)

{

setnum(stringnewnum)

setwriter(stringnewwri)

setpub(stringnewpub)

stringBook:

getname()

returnBookName;

getnum()

returnBooknum;

getwriter()

returnWriter;

getpub()

returnPublisher;

setstate(intstate)

Borrowbooks()

Bookstate=LENDSTATUE;

returnbooks()

Bookstate=NORMALSTATUE;

intBook:

getstate()

returnBookstate;

~Book(void)

/************************************************************************************************************************

Bookmanage.cpp       

 2012-4-03~2012-4-7,2012-5-28进行修改添加tag

*************************************************************************************************************************/

Bookmanage.h"

fstream>

/**************************************************实现将books.txt文本文件中的book读取到vector向量中,以便对图书的相关操作*/

Bookmanage:

Bookmanage(void)

count=0;

ifstreamfin("

books.txt"

);

while(true)

stringname;

stringnumber;

stringwriter;

stringpublisher;

intstate;

if(fin.eof())break;

fin>

>

name>

number>

writer>

publisher>

state;

if(name!

="

Bookbook(name,number,writer,publisher,state);

books.push_back(book);

count++;

/******************************************************************用来获得文件中所存放的book的数目*/

}

fin.close();

voidBookmanage:

addBooks()

\t*********************请输入图书的书名*********************"

cin>

name;

\t*********************请输入图书的书号ISBN*****************"

number;

\t*********************请输入图书的作者*********************"

writer;

\t*********************请输入图书的出版社*******************"

publisher;

\t**********************确定输入的信息是否正确,Y/N*********"

chark;

k;

if(k=='

Y'

Bookbook(name,number,writer,publisher,0);

books.push_back(book);

/********************************************************************将book存放push_back到books向量中*/

count++;

\t*******添加图书成功,此本书为图书馆中的第"

count<

本书*********"

else

\t*****************************添加图书失败**************************"

/*******************************************************************************************************实现查找图书的功能*/

findBook()

charchoice;

stringwant;

inti;

inttag;

/***************************************************************************************标记以便确认是否查找到图书*/

\t*********************选择您要查找图书的方式*********************"

<

endl<

a:

\t书名\tb:

\tISBM\tc:

\t书名作者\td:

\t出版社"

/**************************************选择查找图书的方式*/

choice;

switch(choice)

case'

a'

cout<

cin>

want;

cin.get();

for(i=tag=0;

i<

count;

i++)

{

if(books.at(i).getname()==want)

{

tag=1;

/**********************************************************************当图书馆中存在图书是讲tag赋值为1*/

if(books.at(i).getstate()==0)

{

books.at(i).displayInfo();

cout<

\t**********很高兴您所查找的图书在图书库中!

**************"

"

\t*********为图书库中的第"

i+1<

本图书!

********************"

\t*********请记住此本图书的位置以方便您的借阅*************"

system("

pause"

}

else

cout<

\t***************很抱歉您所查找的图书已经不在图书馆了!

***********"

}

if(tag==0)/****************************************************************如果图书馆中原本就不存在查找的图书的tag是0*/

\t***************很抱歉您所查找的图书不存在!

***************"

system("

break;

b'

/********************安图书的书号进行查找*/

for(inti=tag=0;

if(books.at(i).getnum()==want)

\t*********很高兴您所查找的图书在图书库中!

/**************方便图书的借阅*/

\t*********请记住此本图书的位置以方便您的借阅************"

if(tag==0)

break;

c'

\t*********************请输入图书的作者\t*******************"

if(books.at(i).getwriter()==want)

d'

\t*********************请输入图书的出版社\t*****************"

if(books.at(i).getpub()==want)

default:

\t******************************%d为非法选项!

****************\n"

/***********************************************************************************************************实现图书的借出*/

lendbook()

inti=0;

\t*********请输入您需要借阅的图书的编号********************"

endl

\t*********即为第几本书,比如2***************************"

i;

if(i<

=count)

Book&

temp=books.at(i-1);

temp.displayInfo();

if(temp.getstate()==0)

\t************是否为你想要的图书,确定是否借阅Y/N*******"

charc;

cin>

c;

if(c=='

temp.Borrowbooks();

\t*************恭喜

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1