OOP课程设计报告
来源:互联网 发布:轻淘客和淘宝联盟区别 编辑:程序博客网 时间:2024/06/15 18:08
《面向对象程序设计》课程设计报告
设计题目
图书信息管理系统
学生姓名
陈海燕
学生班级
信管1141班
学生学号
201411671101
指导教师
易学明
完成时间: 2015 年 07月 02 日
1、设计目的:
设计该图书管理系统,要求学生达到熟练掌握C++语言的基本知识和技能,能够基本掌握面向对象程序设计的基本思路和方法,能够利用所学的基本知识和技能解决简单的面向对象程序设计的问题。另外,通过该课程设计的实践,来提高学生动手编程解决实际问题的能力,加深对C++语言及解决问题方法的理解,为以后的学习打下坚实的基础。
2、设计内容:
设计一个C++程序来管理图书信息,能实现图书相关信息的具备数据的输入、查找、删除等功能,能实现。
3、系统功能需求分析:
由对图书管理系统的问题描述可知,该系统主要功能应该包括借阅书刊,归还书刊,取消书刊预约信息,录入书刊,显示用户信息,查询书刊信息,退出系统等功能。同时,在借阅书刊和显示用户信息的功能中还应有有注册用户信息的功能。如果用户在借阅书刊和显示用户信息的的时候,若用户数据库中没有该用户,则提示用户是否注册用户信息。并且,在借阅书刊时,若该书刊已借,用户可以预约该书刊。另外,在归还书刊的功能中,应该有预约该书刊的用户可依预约时间的先后来获得该书刊。在进入取消书刊预约信息的时候,应该根据用户输入的基本信息(借阅名,借阅卡号)首先来显示用户基本信息,再根据基本信息是否来进行取消已预约书刊记录信息的功能。
依以上对系统所需功能的分析,为了实现上述的各个功能,首先应该要建立合适的数据结构,为实现以上各个功能的基本运算而进行合理的数据存储及组织。显然,在该系统中的基本运算主要是数据元素的查找、删除、插入等。数据元素应该是账户信息,账户信息内又包括用户的个人基本信息、借阅信息、以及预约信息。另外,为了能够借阅书刊以及查询书刊信息,应该还要建立对图书信息的存储和组织的数据结构,在该数据结构中,图书信息即为该数据结构的数据元素。
以下对数据元素进行详细的分析。对于账户信息,其包括个人信息、借阅信息、以及预约信息。这些信息可以定义类来实现,并把个人信息类、借阅信息类、预约信息类嵌套在账户信息类里,作为它的私有成员;对于图书信息,则可定义图书信息类。账户信息和图书信息仅仅只是针对单一对象的信息,如要存储多个这样对象的信息,则必须构建一个合适的数据结构来存储和组织这些信息。由系统功能可知,应该选用链表来存储账户信息和图书信息比较合适。所以可以定义链表类来对账户信息和图书信息进行存储和组织。另外,某一个用户借阅或预约的书刊可能有多本,故也可以定义链表类来存储和组织这些信息,在把链表类嵌套到账户类里。
4、总体设计:
(1)系统功能分析:
该系统主要功能包括借阅书刊、归还书刊、取消书刊预约信息、录入书刊,显示用户信息、查询书刊信息、退出系统等。进入该系统后,便出现选择这些功能的菜单,可依选择项进入相应的功能模块。执行某一功能(除了退出系统)后又可返回功能选项菜单界面。所以在主函数中需要采用函数嵌套。
依系统功能分析有:功能模块流程图如下:
系统功能模块流程图
(2)系统功能模块划分与设计
以下对各功能模块进行分析与设计:
① 借阅书刊功能
首先输入书刊名、书刊的ISBN/ISSN号、借阅者名、借阅卡号。然后依借阅者名及借阅卡号在账户类链表中查找该用户是否存在。若不存在,则返回到注册账号。反之,则依ISBN/ISSN号在图书类中查找并判断该书是否已借阅。(书刊是否被借阅,可以在图书类中定义某一变量进行标记,以此来判断该书刊是否被借阅)若借阅,用户则可预约该书刊或结束借阅书刊功能,借阅书刊失败。反之则借阅书刊成功,并作相应的数据记录。另外,在预约书刊后,若预约的书刊被归还,则立即寄给预约人,并作相应的数据记录。(若有多人预约同一本书,应按预约时间的先后,来确定寄给书刊的预定人)。
② 归还书刊功能
首先输入用户名及借阅卡号,并依次在账户类链表中查找到该账户。若未查找则提示用户可能输入信息错误并要求重新输入。若查找到,则输入书刊名及书刊ISNB/ISSN号,并由此在图书类链表中查找该书刊是否存在,若未查找到则提示书刊信息输入错误并要求重新输入。若书刊存在,则输出归还书刊成功,并作相应的数据记录。同时,还要在账户类链表中查找已预约该书刊的用户,并找到最早预约该书刊的用户,将书刊寄送给该用户,并对该用户信息做相关的记录。
③ 查询书刊功能
查询书刊应根据书刊名在图书类链表中来查找该书刊。查找方法应该为顺序查找。若图书类链表中无要查找的书刊,则输出图书馆内无该书;反之,则输出该书的基本信息,基本信息包括:书名、ISNB/ISSN号、价格、是否借阅等信息。有时同名书刊不只一本,故每查找到一本该书刊则显示该书刊信息,直至遍历整个图书类链表。书刊是否被借阅可设定一变量来表记。
④ 取消书刊预约功能
首先输入借阅者名及借阅卡号,并依此在账户类链表中查找该用户是否存在。若未查到,则提示用户可能输入信息错误并要求重新输入。若查到则显示用户信息,并依此是否进行书刊预约功能。若进行,则输入书刊名及书刊ISNB/ISSN号,并在图书类链表内验证输入信息是否正确。
⑤ 显示用户信息功能
首先输入借阅者名及借阅卡号,并依此在账户类链表里查找该用户是否存在。若未查找的到,则提示用户可能输入信息有误或该用户未注册。反之则显示该用户信息。
⑥ 录入书刊信息功能
录入书刊信息,首先要录入书刊的数量,然后依次输入书刊名、书刊ISNB/ISSN号、书刊定价。这样即可录入书刊信息。
5、系统详细设计:
(1)数据类型及类层次图
该系统所需数据类型主要为字符数组类型,即用字符串类型来定义数据。用字符串定义数据可用string类代替,定义成string类型的数据,对字符的操作更简单。在输入string类数据时,用输入流中的操作符>>来输入字符串,这样需特别注意在输入某一字符串时,其间不能输入空格,否则该输入的字符将会转到下个将要输入的字符串变量,使输入变得混乱。这是由于输入流操作符在输入数据时,若遇到空格,则表示该输入已结束。
该系统中定义的类包括:日期类、个人信息类、借阅书刊信息类、预约书刊信息类、账户信息类、图书类、借阅和预约、账户、图书信息链表类。其类UML图及类层次图如下所示:①日期类
Date
-year:int
-month:int
-day:int
+Date(y:int=0,m:int=0,d:int=0)
+Date(D:const Date&)
+Getyear():int
+Getmonth():int
+Getday():int
+Dashow():void
+DaInput():Date
②个人信息类
UnitInfo
-name:string
-reid:string
-id:string
-sex:string
-D:Date
+UnitInfo(n:string,re: string,id:string,s:string,d:Date)
+UnitInfo()
+UnitInfo(U:const UnitInfo&)
+Getname():string
+Getreid():string
+Unshow():void
+UnInput():UnitInfo
③借阅信息类
④借阅信息链表类
⑤预约信息类
⑥预约信息链表类
TrList
-front:TrothInfo*
-rear:TrothInfo*
-size:int
+TrList()
+insertRear(itme:const TrothInfo&):void
+seekList(INSB:const string&):TrothInfo*
+deletecurr(INSB:const string&):bool
+Trshow():void
+GetTLDate(INSB:const string&):Date
⑦账户类
Account
-U:Unit
-L:LeList
-T:TrList
-next:Account*
+Account(u:Unit,l:LeList,t:TrList)
+Account()
+AUInput():void
+ALInput(L:const LendInfo&):void
+ATInput(T:const TrothInfo&):void
+deleteLeInfo(ISNB:const string&):bool
+deleteTrInfo(ISNB:const string&):bool
+Acshow():void
+Acname():string
+Acreid():string
+GetNext():Account*
+SetNext(A:Account*):void
+GetTrDate(ISNB:const string&):Date
+SeekTr(ISNB:const string&):bool
⑧账户链表类
AcList
-frist:Account*
-last:Account*
-size:int
+~AcList()
+AcList()
+Getfront():Account*
+GetLast():Account*
+SeekAList(n:const string,id:const string):Account*
+SeekActr(ISNB:const string &):Account*
+InsertLast(item:const string &):void
<<friend>>+CompareTime(D1:Date&,D2:Date&):bool
⑨图书类
⑩图书链表类
(1) 图书管理系统模型图
(2)图书管理模式图
LiList
6、实习总结与体会:
通过此次课程设计,更加深了对C++面向对象程序设计语言的知识和设计方法的理
解,也深刻认识了自己在这方面的不足之处。首先,在设计该系统时,对问题描述进行了比较深的认识,并确定了系统所需的数据结构及数据的封装模式,也应用了一些面向对象程序设计的基本方法。特别在此次设计中对数据引用的认识更加深刻,引用作为函数形参,能够通过形参而该变实参值,这一技术的使用非常方便有效。同时,通过这次系统的课程设计过程,更进一步认识了自己的在编程方面的一些不足的方面,尤其表现在逻辑思维不够严密,这方面还需在以后更多的训练中,来弥补这方面的不足。但在修改语法错误方面,基本上还是能够修改。
然后,对课题进行了分析并编写了程序,且进行了调试。至此,由于在设计开始,未为整个系统进行整体及整个编写过程的详细思考,使编写的程序的健壮性不是特别的强,且代码复用性做得不够好,由于数据结构的设计比较直接,未能使用更好的算法,使程序代码较为繁琐,而难以用文件方式对数据进行永久保存,这也就使系统的实际使用价值大大地降低了。所以,在设计某系统时,不仅仅只是对其功能模块进行简单的分析,而且更要使功能模块和设计的数据结构结合起来,以此设计更好的算法,编写出更好,更实用的程序。于是,设计前的系统分析工作是非常重要的,这是程序设计思路的来源。
7、附录: 源程序清单:
#include<iostream>
#include<string>
#include<cstddef>
using namespace std;
//定义日期类
class Date{
private:
intyear;
intmonth;
intday;
public:
Date(inty=0,int m=0,int d=0):year(y),month(m),day(d){}
Date(constDate&D):year(D.year),month(D.month),day(D.day){}
intGetyear(){return year;}
intGetmonth(){return month;}
intGetday(){return day;}
voidDashow();
DateDaInput();
~Date(){}
};
Date Date::DaInput(){
inty,m,d;
cout<<"****************年:";
cin>>y;
cout<<"****************月:";
cin>>m;
cout<<"****************日:";
cin>>d;
returnDate(y,m,d);
}
void Date::Dashow(){
cout<<year<<""<<"年"<<" "<<month<<""<<"月"<<""<<day<<" "<<"日"<<endl;
}
//个人信息类
class UnitInfo{
private:
stringname;
stringreid;
stringid;
stringsex;
DateD;
public:
UnitInfo(stringn,string re,string id,string sex,Date d):name(n),
Reid(re),id(id),sex(sex),D(d){}
UnitInfo():name(" "),reid(" "),id(" "),sex(" "),D(0,0,0){};
UnitInfo(constUnitInf &Info):name(Info.name),reid(Info.reid),
id(Info.id),sex(Info.sex),D(Info.d){}
stringGetname(){return name;}
stringGetreid(){return reid;}
voidUnshow();
UnitInfoUnInput();
~UnitInfo(){}
};
UnitInfo UnitInfo::UnInput(){
stringn,r,i,s;
Dated;
cout<<" 借阅卡号:";
cin>>r;
cout<<endl;
cout<<" 用户姓名:";
cin>>n;
cout<<endl;
cout<<" 性别 :";
cin>>s;
cout<<endl;
cout<<" 身份证号:";
cin>>i;
cout<<endl;
cout<<" 出生日期:"<<endl;
d=d.DaInput();
return UnitInfo(n,r,i,s,d);
}
void UnitInfo::Unshow(){
cout<<" 借阅卡号:"<<reid<<endl;
cout<<" 用户姓名:"<<name<<endl;
cout<<" 性别 :"<<sex<<endl;
cout<<" 身份证号:"<<id<<endl;
cout<<" 出生日期:";
D.Dashow();
}
//借阅信息类
class LendInfo{
private:
stringbookname;
stringISBN;
DateD;
LendInfo*next;
public:
LendInfo(stringn,string h,Date d):bookname(n),ISBN(h),D(d),
next(NULL){}
LendInfo():bookname(" "),ISBN(" "),next(0){}
LendInfo(constLendInfo&L):bookname(L.bookname),ISBN(L.ISBN),
D(L.D),next(L.next){}
stringGetINSB(){return ISBN;}
voidsetnext( LendInfo*L){next=L;}
LendInfo*Getnext(){return next;}
voidLeshow();
LendInfoLeInput();
};
LendInfo LendInfo::LeInput(){
stringn,I;
Dated;
cout<<"书名 :";
cin>>n;
cout<<"书号 :";
cin>>I;
cout<<"借阅日期:"<<endl;
d=d.DaInput();
returnLendInfo(n,I,d);
}
void LendInfo::Leshow(){
cout<<" 书名 :"<<bookname<<endl;
cout<<" 书号 :"<<ISBN<<endl;
cout<<" 借阅日期:";
D.Dashow();
}
//借阅书刊链表类
class LeList{
private:
LendInfo*front,*rear;
intsize;
public:
LeList():front(0),rear(0),size(0){}
void insertRear(const LendInfo&item);
LendInfo*seekList(const string INSB);
booldeletecurr(const string INSB);
voidLeshow();
~LeList();
};
void LeList::insertRear(constLendInfo&item){
LendInfo*currPtr=new LendInfo(item);
if(size==0){
front=rear=currPtr;
}
else{
rear->setnext(currPtr);
rear=currPtr;
}
size++;
}
LendInfo* LeList::seekList(const stringINBS){
LendInfo*Pointer=front;
LendInfo*ccurPtr=0;
while(Pointer!=0){
if(INBS==Pointer->GetINSB())
{
ccurPtr=Pointer;
break;
}
Pointer=Pointer->Getnext();
if(Pointer==0)
cout<<" 用户没有借阅这本书"<<endl;
}
returnccurPtr;
}
bool LeList::deletecurr(const string INSB){
LendInfo*currPtr=seekList(INSB);
LendInfo*Pointer=front;
boolmark=false;
if(currPtr!=0&&Pointer!=0)
{ if(size==1){
deletePointer;
front=rear=NULL;
mark=true;}
elseif(currPtr==front){
front=Pointer->Getnext();
delete Pointer;
mark=true;
}
else{
while(Pointer->Getnext()!=currPtr)
Pointer=Pointer->Getnext();
Pointer->setnext(currPtr->Getnext());
deletecurrPtr;
mark=true;
}
size--;
}
else
cout<<" 用户没有该书的借阅信息!"<<endl;
returnmark;
}
void LeList::Leshow(){
LendInfo*Pointer=front;
if(size!=0)
while(Pointer!=0){
Pointer->Leshow();
Pointer=Pointer->Getnext();
}
elsecout<<" 用户无任何借阅记录!"<<endl;
}
LeList::~LeList(){
if(size!=0){
cout<<"DestryingLendInfos...\n";
LendInfo*currPtr=front;
LendInfo*temPtr;
while(currPtr!=0){
temPtr=currPtr;
temPtr->Leshow();
currPtr=currPtr->Getnext();
delete temPtr; }
}
}
//预约书刊类
class TrothInfo{
private:
stringbookname;
stringISBN;
DateD;
TrothInfo*next;
public:
TrothInfo(stringn,string h,Dated):bookname(n),ISBN(h),D(d),
next(NULL){}
TrothInfo():bookname(" "),ISBN(" "),next(NULL){}
TrothInfo(constTrothInfo&L):bookname(L.bookname),ISBN(L.ISBN),
D(L.D),next(L.next){}
stringGetINSB(){return ISBN;}
voidsetnext( TrothInfo*L){next=L;}
TrothInfo*Getnext(){return next;}
voidTrshow();
TrothInfoTrInput();
DateGetDate(){return D;}
};
TrothInfo TrothInfo::TrInput(){
stringn,I;
Dated;
cout<<"书名 :";
cin>>n;
cout<<"书号 :";
cin>>I;
cout<<"借阅日期:"<<endl;
d=d.DaInput();
returnTrothInfo(n,I,d);
}
void TrothInfo::Trshow(){
cout<<" 书名 :"<<bookname<<endl;
cout<<" 书号 :"<<ISBN<<endl;
cout<<" 借阅日期:";
D.Dashow();
}
//预约书刊链表类
class TrList{
private:
TrothInfo*front,*rear;
int size;
public:
TrList():front(0),rear(0),size(0){}
void insertRear(const TrothInfo&item);
TrothInfo*seekList(const string& INSB);
booldeletecurr(const string& INSB);
voidTrshow();
~TrList();
DateGetTLDate(const string& INSB);
};
void TrList::insertRear(constTrothInfo&item){
TrothInfo*currPtr=new TrothInfo(item);
if(size==0){
front=rear=currPtr;
}
else{
rear->setnext(currPtr);
rear=currPtr;
}
size++;
}
TrothInfo* TrList::seekList(conststring& INBS){
TrothInfo*Pointer=front;
TrothInfo*ccurptr=0;
while(Pointer!=0){
if(Pointer->GetINSB()==INBS)
{
ccurptr=Pointer;
break;
}
Pointer=Pointer->Getnext();
if(Pointer==0)
cout<<" 用户没有预约这本!"<<endl;
}
returnccurptr;
}
bool TrList::deletecurr(const string&INSB){
TrothInfo*currPtr=seekList(INSB);
TrothInfo*Pointer=front;
boolmark=false;
if(currPtr!=0&&Pointer!=0)
{ if(size==1){
deletePointer;
front=rear=0;
mark=true;}
elseif(currPtr==front){
front=Pointer->Getnext();
deletePointer;
mark=true;
}
else{
while(Pointer->Getnext()!=currPtr)
Pointer=Pointer->Getnext();
Pointer->setnext(currPtr->Getnext());
deletecurrPtr;
mark=true;}
size--;
}
else
cout<<" 用户没有预约该书的信息!"<<endl;
returnmark;
}
void TrList::Trshow(){
TrothInfo*Pointer=front;
if(size!=0)
while(Pointer!=0){
Pointer->Trshow();
Pointer=Pointer->Getnext();
}
elsecout<<" 用户无任何预约记录!"<<endl;
}
TrList::~TrList(){
if(size!=0){
cout<<"DestryingLendInfos...\n";
TrothInfo*currPtr=front;
TrothInfo*temPtr;
while(currPtr!=0){
temPtr=currPtr;
temPtr->Trshow();
currPtr=currPtr->Getnext();
delete temPtr; }
}
}
Date TrList::GetTLDate(const string&INSB){
TrothInfo*T=seekList(INSB);
DateD;
if(T!=0)
returnT->GetDate();
elsereturn D;
}
//账户类
class Account{
private:
UnitInfoU;
LeListL;
TrListT;
Account*next;
public:
Account(UnitInfou,LeList l,TrList t):U(u),L(l),T(t),next(0){}
Account():U(),L(),T(){};
voidAUInput();
voidALInput(const LendInfo&L);
voidATInput(const TrothInfo&Tr);
booldeleteLeInfo(const string& INBS){return L.deletecurr(INBS);}
booldeleteTrInfo(const string& INBS){return T.deletecurr(INBS);}
voidAcshow();
stringAcname(){return U.Getname();}
stringAcreid(){return U.Getreid();}
Account*GetNext(){returnnext;}
voidSetNext(Account*A){next=A;}
~Account();
DateGetTrDate(const string& INSB){return T.GetTLDate(INSB);}
boolSeekTr(const string &INBS);
friendifstream;
};
bool Account::SeekTr(const string&INBS){
boolmark=false;
if(T.seekList(INBS)!=0)
mark=true;
returnmark;
}
void Account::AUInput(){
U=U.UnInput();
next=0;
}
void Account::ALInput(constLendInfo&Le){
L.insertRear(Le);
}
void Account::ATInput(constTrothInfo&Tr){
T.insertRear(Tr);
}
void Account::Acshow(){
cout<<"用户基本信息:"<<endl;
cout<<" 个人信息:"<<endl;
U.Unshow();
cout<<endl;
cout<<" 借阅信息:"<<endl;
L.Leshow();
cout<<endl;
cout<<" 预约信息:"<<endl;
T.Trshow();
cout<<endl;
}
Account::~Account(){
U.~UnitInfo();
L.~LeList();
T.~TrList();
}
//账户链表类
class AcList{
private:
Account*front,*last;
intsize;
public:
AcList():front(0),last(0),size(0){}
voidInsertLast(const Account &item);
Account*GetFront(){returnfront;}
Account*GetLast(){returnlast;}
Account*SeekAList(conststring n,const string id);
Account*SeekAcTr(conststring &INBS);
friendbool CompareTime(Date&D1,Date&D2);
};
Account*AcList::SeekAcTr(const string&INBS){
Account*Pointer=front;
Account*currPtr=0;
inti=0;
if(Pointer!=0)
while(Pointer!=0){
if(Pointer->SeekTr(INBS)){
i++;
if(i==1)
currPtr=Pointer;
}
if(i==2){
if(CompareTime(Pointer->GetTrDate(INBS),currPtr->GetTrDate(INBS)))
currPtr=Pointer;
i=1;
}
Pointer=Pointer->GetNext();
}
returncurrPtr;
}
void AcList::InsertLast(constAccount&item){
Account*Pointer=newAccount(item);
if(size==0)
front=last=Pointer;
else{
last->SetNext(Pointer);
last=Pointer;}
size++;
}
Account*AcList::SeekAList(const stringn,const string id){
Account*Pointer=front;
Account*ccurPtr=0;
if(size!=0){
while(Pointer!=0){
if(Pointer->Acname()==n&&Pointer->Acreid()==id){
ccurPtr=Pointer;
break;}
Pointer=Pointer->GetNext();
if(Pointer==0)
cout<<" 用户数据库中没有该用户"<<endl;
}
}
returnccurPtr;
}
//图书类
class Library{
private:
stringbookname;
stringISBN;
floatPrices;
boolPointer;
Library*next;
public:
Library(stringbn,string IS,float Prices):bookname(bn),ISBN(IS),
Prices(Prices),Pointer(true),next(0){}
Library():bookname(" "),ISBN(" "),Prices(0) ,Pointer(true),
next(0){}
Library(constLibrary&Li):bookname(Li.bookname)
,ISBN(Li.ISBN),Prices(Li.Prices),next(0){}
LibraryLiInput();
voidLishow();
boolGetPointer(){return Pointer;}
Library*GetNext(){returnnext;}
stringGetBookName(){return bookname;}
stringGetISSN(){return ISBN;}
voidSetNext(Library*L){next=L;}
voidSetPointer(const bool T){Pointer=T;}
~Library(){}
};
Library Library::LiInput(){
stringn,IS;
floatP;
cout<<" 书名 :";
cin>>n;
cout<<" 书号 :";
cin>>IS;
cout<<" 定价¥:";
cin>>P;
returnLibrary(n,IS,P);
}
void Library::Lishow(){
cout<<"书刊基本信息:"<<endl;
cout<<" 书名 :"<<bookname<<endl;
cout<<" 书号 :"<<ISBN<<endl;
cout<<" 定价¥ :"<<Prices<<endl;
cout<<" 书刊是否可借:";
if(Pointer)
cout<<"书刊可借"<<endl;
elsecout<<"书刊已借"<<endl;
}
//图书链表类
class LiList{
private:
Library*front,*last;
intsize;
public:
LiList():front(0),last(0),size(0){}
voidInstrelast(const Library&Li);
Library*GetFront(){returnfront;}
Library*LiSeek(const string name,const string INSB);
voidLiSeek(const string);
};
voidLiList::Instrelast(const Library&item){
Library*Pointer=newLibrary(item);
if(size==0)
front=last=Pointer;
else{
last->SetNext(Pointer);
last=Pointer;}
size++;
}
Library* LiList::LiSeek(const stringname,const string INBS){
Library*Pointer=front;
Library*ccurPtr=0;
if(Pointer==0)
cout<<" 图书数据库中没有任书籍!"<<endl;
else{
while(Pointer!=0){
if(Pointer->GetBookName()==name&&Pointer->GetISSN()==INBS){
ccurPtr=Pointer;
break;
}
Pointer=Pointer->GetNext();
if(Pointer==0)
cout<<" 图书数据库中没有该书籍!"<<endl;
}
}
returnccurPtr;
}
void LiList::LiSeek(const string name){
Library*Pointer=front;
if(Pointer==0){
cout<<" 图书数据库中没有任书籍!"<<endl;
}
else{
while(Pointer!=0){
if(Pointer->GetBookName()==name){
Pointer->Lishow();
cout<<endl;
}
Pointer=Pointer->GetNext();
if(Pointer==0){
cout<<" 图书数据库中没有该书籍!"<<endl;
}
}
}
}
//时间比较函数
bool CompareTime(Date&D1,Date&D2){
boolmark=false;
if(D1.Getyear()<D2.Getyear())
mark=true;
if(D1.Getyear()==D2.Getyear()){
if(D1.Getmonth()<D2.Getmonth())
mark=true;
if(D1.Getmonth()==D2.Getmonth())
if(D1.Getday()<=D2.Getday())
mark=true;
}
returnmark;
}
//注册账户
Account*creat( AcList& A){
AccountAc;
Ac.AUInput();
A.InsertLast(Ac);
returnA.GetLast();
}
//借阅书刊
void BorrowBook( AcList& A, LiList&L){
cout<<endl<<"--------------------借阅书刊
--------------------"<<endl;
DateD;
stringbookname,ISBN,name,id;
cout<<"用户输入基本信息如下:"<<endl;
cout<<" 书刊名 :";
cin>>bookname;
cout<<" 书刊号 :";
cin>>ISBN;
cout<<" 借阅者姓名:";
cin>>name;
cout<<" 借阅卡号 :";
cin>>id;
cout<<endl<<"借阅书刊信息提示如下:"<<endl;
Account*Pointer1=A.SeekAList(name,id);
while(true){
if(Pointer1==0){
charc=' ';
cout<<" 用户库中没有该用户!用户是否注册账号?请输入Y或N:";
while(c!='N'&&c!='Y'){
cin>>c;
cout<<endl;
if(c=='N')
cout<<" 用户库中将不会录入用户的信息,不能借阅书刊!"<<endl;
else if(c=='Y'){
cout<<"注册用户信:"<<endl;
Pointer1=creat(A);}
else
cout<<" 输入的选项错误!请重新输入!"<<endl;
}
if(c=='N')break;
}
Library*Pointer2=L.LiSeek(bookname,ISBN);
if(Pointer2!=0){
if(Pointer2->GetPointer()!=false){
cout<<" 借阅书刊成功!"<<endl<<endl;
cout<<"借阅书刊日期:"<<endl;
D=D.DaInput();
LendInfoLe(bookname,ISBN,D);
Pointer1->ALInput(Le);
Pointer2->SetPointer(false);
break;
}
else{
cout<<" 该书刊已借!是否预约该书刊?Y/N:";
strings=" ";
while(s!="Y"&&s!="N"){
cin>>s;
cout<<endl;
if(s=="Y"){
cout<<" 预约书刊成功!"<<endl;
cout<<"预约书刊日期:"<<endl;
D=D.DaInput();
TrothInfoTr(bookname,ISBN,D);
Pointer1->ATInput(Tr);
}
elseif(s=="N"){
cout<<" 借阅书刊失败!"<<endl;
}
else
cout<<" 输入的选项错误!请重新输入!"<<endl;
}
break;
}
}
else
{cout<<" 借阅书刊失败!"<<endl;break;}
}
}
//归还书刊
void ReturnBook(AcList&A,LiList&L){
cout<<endl<<"--------------------归还书刊
--------------------"<<endl;
stringname,reid,bookname,id;
Account*Pointer=0;
cout<<"输入用户基本信息如下:"<<endl;
while(!Pointer){
cout<<" 用户名 :;
cin>>name;
cout<<" 借阅卡号:";
cin>>reid;
cout<<endl;
Pointer=A.SeekAList(name,reid);
if(Pointer==0){
cout<<endl<<"归还书刊提示信息:"<<endl;
cout<<" 用户输入信息错误!用户库中无该用户。是否重新输入?Y或N:";
charch=' ';
while(ch!='Y'&&ch!='N'){
cin>>ch;
cout<<endl;
if(ch=='N')
cout<<" 输入用户信息错误,您将不能归还书刊!"<<endl;
elseif(ch=='Y')
cout<<" 请重新输入用户基本信息:"<<endl;
elsecout<<" 选择项输入错误,请重新输入选择项!"<<endl;
}
if(ch=='N')break;
}
}
if(Pointer!=0){
cout<<"输入书刊的基本信息:"<<endl;
Library*ccurPtr=0;
while(!ccurPtr){
cout<<" 书刊名:";
cin>>bookname;
cout<<" 书刊号:";
cin>>id;
cout<<"归还书刊提示信息:"<<endl;
ccurPtr=L.LiSeek(bookname,id);
if(ccurPtr==0){
cout<<" 输入书刊信息错误!请检查!是否重新输入信息?Y或N:";
charc=' ';
while(c!='N'&&c!='Y'){
cin>>c;
cout<<endl;
if(c=='N')
cout<<" 因输入书刊信息错误!您将不能还书!"<<endl;
elseif(c=='Y')
cout<<" 请您重新输入书刊信息:"<<endl;
else
cout<<" 输入的选择项错误,请重新输入!"<<endl;
}
if(c=='N') break;
}
}
if(ccurPtr!=0){
cout<<"用户归还书刊提示信息:"<<endl;
if(Pointer->deleteLeInfo(id)){
cout<<" 用户还书成功!"<<endl;
Account*Ptr=A.SeekAcTr(id);
if(Ptr!=0){
cout<<endl;
Ptr->Acshow();
cout<<endl;
if(Ptr->deleteTrInfo(id))
{
cout<<" 预约该书刊的用户成功获得书刊!?"<<endl;
Date d;
cout<<"输入借阅书刊的日期:"<<endl;
d=d.DaInput();
LendInfo Le(bookname,id,d);
Ptr->ALInput(Le);
}
}
else
ccurPtr->SetPointer(true);
}
}
}
}
//显示用户信息
void Show(AcList&A){
cout<<endl<<"---------------显示用户息 --------------------"<<endl;
stringname,id;
Account*Pointer=0;
cout<<"输入用户名及借阅卡号:"<<endl;
while(!Pointer){
cout<<" 借阅卡号:";
cin>>id;
cout<<endl;
cout<<" 用户名 :";
cin>>name;
cout<<"显示用户信息提示:"<<endl;
Pointer=A.SeekAList(name,id);
if(Pointer==0){
cout<<" 输入的用户信息没有在用户库中,可能是输入信息错误或该用户未注册.是否重新输入?Y或N:";
charc=' ';
while(c!='N'&&c!='Y'){
cin>>c;
cout<<endl;
if(c=='N'){
cout<<" 用户库中无该用户,不能显示该用户信息!"<<endl<<endl;
break;}
elseif(c=='Y'){
cout<<" 重新输入信息(Y1)或注册用户信息(Y2).请输入选择项Y1或Y2:";
strings=" ";
while(s!="Y1"&&s!="Y2"){
cin>>s;
cout<<endl;
if(s=="Y1")
cout<<" 请重新输入信息:"<<endl;
elseif(s=="Y2"){
cout<<" 用户注册信息:"<<endl;
Pointer=creat(A);}
else
cout<<" 选择项输入错误!请重新输入!"<<endl;
}
}
else
cout<<" 选择项输入错误!请重新输入!"<<endl;
}
}
}
if(Pointer!=0)
Pointer->Acshow();
}
void Input(LiList &L){
cout<<"--------------------录入书刊信息--------------------"<<endl;
intn;
cout<<"需录入信息的书刊数量:";
cin>>n;
cout<<endl;
Library*Li=newLibrary[n];
for(inti=0;i<n;i++){
Li[i]=Li[i].LiInput();
L.Instrelast(Li[i]);
cout<<endl<<endl;
}
delete[] Li;
}
//取消预约
voidDeleteTrothInfo(AcList&A,LiList&L){
cout<<"--------------------取消书
刊预约 -------------------"<<endl;
stringname,reid,bookname,id;
Account*Pointer=0;
cout<<"输入用户基本信息如下:"<<endl;
while(!Pointer){
cout<<" 用户名 :";
cin>>name;
cout<<" 借阅卡号:";
cin>>reid;
cout<<endl;
cout<<endl<<"取消书刊预约提示信息:"<<endl;
Pointer=A.SeekAList(name,reid);
if(Pointer==0){
cout<<"用户输入信息错误!用户库中无该用户。是否重新输入?Y或N:";
charch=' ';
while(ch!='Y'&&ch!='N'){
cin>>ch;
cout<<endl;
if(ch=='N')
cout<<" 输入用户信息错误,您将不能取消书刊预约!"<<endl;
elseif(ch=='Y')
cout<<"请重新输入用户基本信息:"<<endl;
elsecout<<" 选择项输入错误,请重新输入选择项!"<<endl;
}
if(ch=='N')break;
}
}
if(Pointer!=0){
cout<<endl;
Pointer->Acshow();
cout<<endl<<"用户是否继续执行该操作?请选择Y或N:"<<endl;
charst=' ';
while(st!='Y'&&st!='N'){
cin>>st;
if(st=='Y'){
cout<<"输入书刊的基本信息:"<<endl;
Library*ccurPtr=0;
while(!ccurPtr){
cout<<" 书刊名:";
cin>>bookname;
cout<<" 书刊号:";
cin>>id;
cout<<"取消书刊预约提示信息:"<<endl;
ccurPtr=L.LiSeek(bookname,id);
if(ccurPtr==0){
cout<<"输入书刊信息错误!请检查!是否?重?新输入信息?Y或N:";
charc=' ';
while(c!='N'&&c!='Y'){
cin>>c;
cout<<endl;
if(c=='N')
cout<<" 因输入书刊信息错误!您将不能取消书刊预约!"<<endl;
elseif(c=='Y')
cout<<"请您重新输入书刊信息:"<<endl;
else
cout<<" 输入的选择项错误,请重新输入!"<<endl;
}
if(c=='N') break;
}
}
if(ccurPtr!=0){
cout<<"用户取消书刊预约提示信息:"<<endl;
if(Pointer->deleteTrInfo(id)){
cout<<" 用户取消书刊预约成功!"<<endl;}
}
}
elseif(st=='N')
cout<<" 用户取消书刊预约失败!"<<endl;
else
cout<<"输入选择项错误!请重新输入!"<<endl;
}
}
}
//查询图书信息
void SeekBook(LiList&L){
cout<<endl<<"--------------------查询书信息 --------------------"<<endl;
cout<<"请输入书刊名:";
stringname;
cin>>name;
L.LiSeek(name);
}
AcList A;
LiList L;
int main(){
cout<<"--------------------欢迎进入图书管理系统--------------------"<<endl;
intn;
cout<<" ----------1、录入书刊信息---------- "<<endl;
cout<<" ----------2、借阅书刊 ---------- "<<endl;
cout<<" ----------3、返回书刊 ---------- "<<endl;
cout<<" ----------4、显示用户信息---------- "<<endl;
cout<<" ----------5、取消预约信息---------- "<<endl;
cout<<" ----------6、查询书刊信息---------- "<<endl;
cout<<" ----------7、退出系统 ---------- "<<endl<<endl;
cout<<"**********请用户输入功能选择项:->";
cin>>n;
cout<<endl;
switch(n){
case1:
Input(L);
cout<<endl;
main();
case2:
BorrowBook(A,L);
cout<<endl;
main();
case3:
ReturnBook(A,L);
cout<<endl;
main();
case4:
Show(A);
cout<<endl;
main();
case5:
DeleteTrothInfo(A,L);
cout<<endl;
main();
case6:
SeekBook(L);
cout<<endl;
main();
case7:
cout<<"退出系统!"<<endl;
exit(0);
default:
break;
}
return0;
}
- OOP课程设计报告
- 课程设计报告
- 课程设计报告
- 课程设计报告
- 课程设计报告
- 《C++课程设计》报告
- Mini人事管理系统课程设计报告
- 软件课程设计报告
- 《数据结构》课程设计报告
- 通信原理课程设计报告
- 电子技术课程设计报告
- 计算机网络课程设计报告
- 数据结构课程设计实习报告
- C++课程设计报告
- 数据结构课程设计报告
- 数据结构课程设计报告
- 《数据结构》课程设计报告
- 题目二:课程设计报告
- 黑马-OC语法-@property和@synthesize
- ROS学习手记 - 3 理解ROS中的基本概念_ROS_Nodes
- 线程知识和线程池
- Hadoop小练习——利用MapReduce求平均数
- 51nod 算法马拉松3 A:序列分解
- OOP课程设计报告
- 本纪·重新出发
- [华为机试练习题]58.查找同构数的数量
- OpenGL的版本历史和发展
- 欢迎使用CSDN-markdown编辑器
- 第一篇博客
- 数据结构基础 之 树与二叉树 各类操作、思想与实现
- [LeetCode][Java] Two Sum
- 国嵌C++专题3-八剑齐飞