pull/9/head
yangtengze 2 years ago
parent aac2722502
commit 8c04dcff4d

@ -67,14 +67,12 @@
请选择1
Find Book
Book data empty
```
```
请选择1
Find Book
Enter book ID: 1
Not found
```
@ -82,7 +80,6 @@ Not found
请选择1
Find Book
Enter book ID: 1
Found
************
@ -98,16 +95,13 @@ Book
请选择2
Boorow Book
Book data empty
```
```
请选择2
Boorow Book
Which book you wanna boorow ?
2
Enter book ID:2
NOT FOUND THIS BOOK
```
@ -115,9 +109,7 @@ NOT FOUND THIS BOOK
请选择2
Boorow Book
Which book you wanna boorow ?
1
Enter book ID:1
*********
OK
@ -129,19 +121,17 @@ OK
请选择3
Repaid Book
Which book you wanna repaid ?
2
Enter book ID:2
Add Book
ID : 1
ID : 2
TITLE : 1
Number : 1
Book
**************** id: 1 ****************
**************** id: 2 ****************
**** title: 《 1 》****
************** Number: 1 **************
`````
@ -151,9 +141,7 @@ Book
请选择3
Repaid Book
Which book you wanna repaid ?
1
Enter book ID:1
`````
### C4打印书籍
@ -208,8 +196,6 @@ Book
请选择6
Delete Book
Which book you wanna delelet?
Enter book ID: 4
Book
@ -219,13 +205,12 @@ Book
************************
Deleted
************************
```
```
请选择6
Delete Book
Which book you wanna delelet?
Enter book ID: 5
Not found
```
@ -235,9 +220,7 @@ Not found
请选择7
Revise Book
Which book you wanna revise ?
1
Enter book ID : 1
Original book number : 1
Revised number :2
**********************
@ -249,9 +232,7 @@ Revise success
请选择7
Revise Book
Which book you wanna revise ?
2
Enter book ID : 2
No such book
``````
### C8排序图书
@ -260,14 +241,12 @@ No such book
请选择8
Sort Books
Book data empty
```
```
请选择8
Sort Books
*****************************
Sort success
```
@ -329,7 +308,7 @@ Step 6: if 没找到 then 提示Not found
![find](Graph\DoFindBook.drawio.svg)
## DoDeleteBook
```
Step 1: 提示删除图书和要删除那本书?
Step 1: 提示删除图书
Step 2: 输入图书编号
Step 3: if 存在此图书 then 输出图上述信息 并提示 Deleted
Step 4: if 不存在此图书 then 提示 Not found
@ -344,9 +323,18 @@ Step 3: 显示总书籍个数
![print](Graph\DoPrintBook.drawio.svg)
## DoRepaidBook
```
Step 1: 提示归还图书和哪本书是要还的
Step 1: 提示归还图书
Step 2: 输入图书编号
Step 3: if 存在该书 then 图书数量变化 1
Step 4: if 不存在该书 then 添加此图书
```
![repaid](Graph\DoRepaidBook.drawio.svg)
![repaid](Graph\DoRepaidBook.drawio.svg)
## DoBoorowBook
```
Step 1: 提示借用图书
Step 2: if 图书库为空 then 提示 Books data empty
Step 3: 输入图书编号
Step 4: if 此书存在 if 数量不小于0 then 进行程序并提示 OK 以表示完成 else 提示 Book empty
Step 5: if 此书不存在 then 提示 NOT FOUND THIS BOOK
```
![boorow]()

@ -49,7 +49,7 @@ void input(Book& b)
// 打印一本书的信息
void print(const Book& b)
{
cout << "Book " << endl << endl
cout << endl << "Book " << endl
<<"**************** id: " << b.id << " ****************" << endl
<< "**** title: 《 " << b.title << " 》****" << endl
<< "************** Number: " << b.number << " **************" << endl << endl;
@ -84,43 +84,51 @@ bool bookempty()
// 添加图书
void DoAddBook()
{
if (books.length == 256) cout << "Books full" << endl;
cout << endl << "Add Book"<< endl<<endl;
if (books.length == 256) cout << "Books full" << endl;
else{
Book book;
input(book); //输入图书
books.elem[books.length + 1] = book;
books.length++;
print(book);
cout << "*******Added********" << endl;
}
}
// 查找图书
void DoFindBook()
{
cout << endl << "Find Book" << endl <<endl;
cout << endl << "Find Book" << endl;
if (bookempty()) cout << "Book data empty"<< endl;
else {
int id;
cout << "Enter book ID: ";
cin >> id;
Book book;
if (find(id) == 0)
cout << "Not found" << endl;
{
cout << "************" << endl;
cout << "Not found" << endl;
cout << "************" << endl;
}
else
{
book = books.elem[find(id)];
cout << "************" << endl;
cout << "Found" << endl;
cout << "************" << endl;
print(book);
}
}
}
// 删除图书
void DoDeleteBook()
{
cout << endl << "Delete Book" << endl << endl;
cout << endl << "Delete Book" << endl;
int id;
cout << "Which book you wanna delelet?"<<endl;
cout << "Enter book ID: ";
cin >> id;
Book e;
@ -137,6 +145,7 @@ void DoDeleteBook()
--books.length;
cout << "************************" << endl;
cout << "Deleted" << endl;
cout << "************************" << endl;
}
}
@ -144,26 +153,25 @@ void DoDeleteBook()
void DoPrintBook()
{
cout << endl << "Print All Books" << endl <<endl;
int flag = 0;
int number = 0;
for (int i = 0; i < books.length; i++)
{
Book e;
e = books.elem[i + 1];
print(e);
flag++;
number++;
}
cout << "Total: ";
cout << flag;
cout << number;
cout << " books" << endl;
}
// 归还图书
void DoRepaidBook()
{
cout << endl << "Repaid Book" << endl<<endl;
cout << endl << "Repaid Book" << endl;
int id;
cout << "Which book you wanna repaid ? " << endl;
cout << "Enter book ID :" << endl;
cout << "Enter book ID :";
cin >> id;
cout << endl;
if (find(id)){
@ -171,6 +179,7 @@ void DoRepaidBook()
e = books.elem[find(id)];
++books.elem[find(id)].number;
}else{
cout << "Add Book" << endl;
DoAddBook();
}
}
@ -178,13 +187,12 @@ void DoRepaidBook()
// 借用图书
void DoBoorowBook()
{
cout << endl << "Boorow Book" << endl <<endl;
cout << endl << "Boorow Book" << endl ;
int id;
if (bookempty()) cout << "Book data empty"<< endl;
cout << "Which book you wanna boorow ? " << endl;
cout << "Enter book ID :" << endl;
if (bookempty()) cout << "Books data empty"<< endl;
else{
cout << "Enter book ID :";
cin >> id;
cout << endl;
if (find(id)){
if (books.elem[find(id)].number>0) {
Book e;
@ -193,25 +201,26 @@ void DoBoorowBook()
--books.elem[find(id)].number;
}else cout << "***************************"<< endl
<< "Book empty" << endl << "***************************" << endl;
}else cout<< "NOT FOUND THIS BOOK"<<endl;
}else cout<< "NOT FOUND THIS BOOK"<<endl;}
}
// 修改图书
void DoReviseBook()
{
cout <<endl<< "Revise Book" <<endl <<endl;
cout <<endl<< "Revise Book" <<endl ;
int id;
printf( "Which book you wanna revise ?\n" );
cout << "Enter book ID :";
cin >> id;
if ( find(id)!=0 ) {
printf ( "Original book number : %d\n", books.elem[id].number );
printf ( "Original book number : %d\n", books.elem[find(id)].number );
printf ( "Revised number :" );
int xiugai;
scanf ( "%d", &xiugai );
books.elem[id].number+=xiugai;
books.elem[id].number=xiugai;
cout << "**********************" << endl;
printf ( "Revise success \n" );
cout << "**********************" << endl;
}
else printf ( "No such book\n");
}
@ -219,12 +228,12 @@ void DoReviseBook()
// 排序图书
void DoSortBook()
{
cout << endl << "Sort Books" << endl << endl;
cout << endl << "Sort Books" << endl;
int a=0;
if (bookempty()) cout << "Book data empty"<< endl;
else {
for (int i=1;i<books.length;i++)
for (int j=books.length;j>0;j--)
for (int i=1;i<books.length-1;i++)
for (int j=2;j<books.length;j++)
{
if (books.elem[i].id>books.elem[j].id) {
Book temp=books.elem[i];books.elem[i]=books.elem[j];books.elem[j]=temp;}
@ -232,5 +241,6 @@ void DoSortBook()
}
cout << "*****************************" <<endl;
cout << "Sort success"<<endl;
cout << "*****************************" <<endl;
}
#endif // DATA_H_INCLUDED
Loading…
Cancel
Save