parent
1ecdddedae
commit
d9de048f86
@ -0,0 +1,61 @@
|
||||
#include<iostream>
|
||||
#include"library.h"
|
||||
#include"book.h"
|
||||
using std::cout;
|
||||
using std::cin;
|
||||
using std::endl;
|
||||
extern Book booklist[50];
|
||||
extern int num;
|
||||
void wxy::jieshu()
|
||||
{
|
||||
char ch;
|
||||
cin.get(ch);
|
||||
if (num == 0)
|
||||
{
|
||||
cout << "Sorry,there are no books in the library,so borrowing books is not supported." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int g{1};
|
||||
int xv{};
|
||||
cout << "Please input the name of the book" << endl;
|
||||
char name[80];
|
||||
cin.getline(name, 80);
|
||||
cin.clear();
|
||||
for (int i{}; i < num; i++) {
|
||||
if (strcmp(name, booklist[i].Name) == 0) {
|
||||
g = 0;
|
||||
xv = i;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (g)
|
||||
{
|
||||
cout << "there is no such book" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (booklist[xv].amount == 0)
|
||||
{
|
||||
cout << "Sorry,all the books are on loan." << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
booklist[xv].amount--;
|
||||
wxy::daochu();
|
||||
cout << "Successful borrowing!" << endl;
|
||||
}
|
||||
}
|
||||
cout << "wanna go on? press n to quit,press enter to continue" << endl;
|
||||
cin.get(ch);
|
||||
if (ch == 'n' || ch == 'N')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue