/*图书馆*/
//#pragma warning(disable:0461)
#include "global.h"
#include "date.h"
#include "bookdata.h"
#include "readerdata.h"
#include "database.h"
#include "librarian.h"
#include "reader.h"
#include<string>
#include<cstring>
int main()
{
DataBase<BookData>BookBase("books.dat");//打开书籍数据库
DataBase<ReaderData>ReaderBase("readers.dat");//打开读者数据库
char choice = 'X';
while (!(choice == 'E' || choice == 'e'))
{
cout << "(L)ibrarian entry,(R)eader entry,Re(t)urn book,(E)xit:";
cin >> choice;
Librarian* mgr = NULL;
Reader* rdr = NULL;
switch (choice)
{
//管理员登录
case 'l':case 'L':
mgr = new Librarian(101, "zs");
choice = mgr->login();//成功返回X,否则E
while (!(choice == 'E' || choice == 'e'))
{
cout << "(A)dd reader,Add (B)ook,(Q)uery Reader,(P)ut book to shelf.(E)xit:";
cin >> choice;
switch (choice)
{
long id;
char name[40];
case 'a':case 'A':
cout << "Give a reader PIN and input a name:";
cin >> id;
cin.ignore();
cin.get(name, 20, '\n');
ReaderBase.insert(ReaderData(id, name));
break;
case 'b':case 'B':
cout << "Input a book id and name:";
cin >> id;
cin.ignore();
cin.get(name, 40, '\n');
BookBase.insert(BookData(id, name));
break;
case 'q':case 'Q':
cout << "Input a reader's PIN:";
cin >> id;
if (ReaderBase.query(id) == NULL)
{
cout << "No such a reader!" << endl;
}else
{
ReaderBase.query(id)->showData();
}
break;
case 'p':case 'P':
cout << "Input a book id:";
cin >> id;
if (BookBase.query(id) == NULL)
{
cout << "No such a book!" << endl;
}
else {
BookBase.query(id)->setState(SHELF);
}
break;
case 's':case 'S':
ReaderBase.showAllData();
BookBase.showAllData();
break;
case 'e':case 'E':
break;
default:
cout << "Unavailable function!\n";
}
}
delete mgr;
choice = 'X';
break;//管理员退出
//读者登录
case 'r':case 'R':
long PIN, bookId;
int i, t1, t2;
char name[40];
for (i = 0; i < 3; i++)
{
cout << "Input PIN:";
cin >> PIN;
if (ReaderBase.query(PIN) != NULL)
{
rdr = new Reader(PIN);
break;
}
}
if (i == 3)
{
cout << "Check in failed!" << endl;//读者登录失败
choice = 'E';
}
while (!(choice == 'e' || choice == 'E'))
{
cout << "(A)dd book to cart,check (o)ut,(Q)uery book by name,(L)ist my books.(E)xit:";
cin >> choice;
switch (choice)
{
case 'a':case 'A':
cout << "Input a book id:";
cin >> bookId;
if((BookBase.query(bookId)!=NULL)&&(BookBase.query(bookId)->getState()==SHELF))
{
if (rdr->addBook(bookId))
{
BookBase.query(bookId)->setState(LIB);
}
}
break;
case 'o':case'O':
t1 = rdr->getNum();//在书车的图书编号
t2 = ReaderBase.query(PIN)->getNum();//在读者的图书编号
if (t1 > 0 && t2 < LIMIT)
{
cout << PIN << " " << ReaderBase.query(PIN)->getName() << " book list" << endl;
for (i = 0; i < t1 && i < (LIMIT - t2); i++)
{
bookId = ReaderBase.query(PIN)->borrowBook(rdr->checkOut());
BookBase.query(bookId)->setState(READER);
BookBase.query(bookId)->setPIN(PIN);
cout << i + 1 << "\t" << BookBase.query(bookId)->getName() << endl;
}
Date().display();
}
break;
case 'q':case 'Q':
cout << "Input a book name(part):";
cin.ignore();
cin.get(name,40,'\n');
if (BookBase.queryName(name) != NULL)
{
BookBase.queryName(name)->showData();
}
break;
case 'l':case 'L':
ReaderBase.query(PIN)->showData();
break;
case 'c':case 'C':
rdr->showCart();//显示书本在书车的图书编号
break;
case 'e':case 'E':
break;
default:
cout<< "Unavailable function!\n";
}
}
delete mgr;
choice = 'X';
break;//读者退出
//还书入口
case 't':case 'T':
cout << "Input a book id:";
cin >> bookId;
if (BookBase.query(bookId) != NULL)
{
BookBase.query(bookId)->setState(LIB);
if ((PIN = BookBase.query(bookId)->getPIN()) > 0)
{
ReaderBase.query(PIN)->returnBook(bookId);
}
}
break;//退出还书
case 'e':case 'E':
break;
default:
cout << "Unavailable function!\n";
}
}
return 0;
}
JPC客栈
- 粉丝: 2676
- 资源: 28
最新资源
- 5A90铝锂合金电子束焊接接头显微分析 - .pdf
- 5E83铝合金TIG焊接头残余应力分布研究 - .pdf
- 5万m-3LNG储罐9 Ni钢内罐焊接技术.pdf
- 6mm不锈钢对接焊接接头超声检测探讨.pdf
- 07MnNiVDR钢焊接热影响区再热脆化研究 - .pdf
- 07钢管相贯节点焊接缺陷类型及对极限承载力的影响.pdf
- 7A05铝合金激光-MIG复合焊接头组织分析 - .pdf
- 08Cr2AIMoSi板材焊接冷裂纹敏感性及焊后热处理试验.pdf
- 7N01-T4铝合金搅拌摩擦焊接头的组织和耐应力腐蚀性能 - .pdf
- 7N01铝合金焊接接头力学性能及静/动态失效分析 - .pdf
- 08采用冷轧带肋钢筋焊接网的抗震墙性能研究.pdf
- 8轴激光焊接实验平台的有限元分析及优化设计.pdf
- 09CrCuSb钢焊接材料选定及其焊接工艺 - .pdf
- 09MnNiDR低温钢的焊接工艺评定.pdf
- 09MnNiDR低温容器的焊接及热处理研究 - .pdf
- 09MnNiDR低温钢焊接性分析 - .pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
- 6
前往页