diff --git a/Graph/DoBorrowBook.drawio.svg b/Graph/DoBorrowBook.drawio.svg new file mode 100644 index 0000000..8d18502 --- /dev/null +++ b/Graph/DoBorrowBook.drawio.svg @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Graph/DoRepaidBook.drawio.svg b/Graph/DoRepaidBook.drawio.svg index cffecd0..bf1c42a 100644 --- a/Graph/DoRepaidBook.drawio.svg +++ b/Graph/DoRepaidBook.drawio.svg @@ -1,13 +1,13 @@ - + - - - + + + -
+
DoRepaidBook @@ -15,19 +15,19 @@
- + DoRepaidBook - - - - + + + + -
+
提示输入图书ID @@ -35,37 +35,37 @@
- + 提示输入图书ID - + -
+
- 显示还书和哪本书是要还的? + 显示还书
- - 显示还书和哪本书是要还的? + + 显示还书 - - - - - + + + + + -
+
图书存在? @@ -73,19 +73,19 @@
- + 图书存在? - - - - + + + + -
+
DoAddBook @@ -93,16 +93,16 @@
- + DoAddBook - + -
+
N @@ -110,19 +110,19 @@
- + N - - - - + + + + -
+
图书数量加1 @@ -130,12 +130,12 @@
- + 图书数量加1 - + diff --git a/README.md b/README.md index ed9f5c2..52d638f 100644 --- a/README.md +++ b/README.md @@ -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) \ No newline at end of file +![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](Graph\DoBorrowBook.drawio.svg) \ No newline at end of file diff --git a/code/data.h b/code/data.h index 3243ff0..d0f0f88 100644 --- a/code/data.h +++ b/code/data.h @@ -281,7 +281,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; @@ -316,43 +316,51 @@ bool bookempty() // 添加图书 void DoAddBook() { - if (books.length == 256) cout << "Books full" << endl; cout << endl << "Add Book"<< endl<> 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?"<> id; Book e; @@ -369,6 +377,7 @@ void DoDeleteBook() --books.length; cout << "************************" << endl; cout << "Deleted" << endl; + cout << "************************" << endl; } } @@ -376,26 +385,25 @@ void DoDeleteBook() void DoPrintBook() { cout << endl << "Print All Books" << endl <> id; cout << endl; if (find(id)){ @@ -403,6 +411,7 @@ void DoRepaidBook() e = books.elem[find(id)]; ++books.elem[find(id)].number; }else{ + cout << "Add Book" << endl; DoAddBook(); } } @@ -410,13 +419,12 @@ void DoRepaidBook() // 借用图书 void DoBoorowBook() { - cout << endl << "Boorow Book" << endl <> id; - cout << endl; if (find(id)){ if (books.elem[find(id)].number>0) { Book e; @@ -425,25 +433,26 @@ void DoBoorowBook() --books.elem[find(id)].number; }else cout << "***************************"<< endl << "Book empty" << endl << "***************************" << endl; - }else cout<< "NOT FOUND THIS BOOK"<> 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"); } @@ -451,12 +460,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;i0;j--) + for (int i=1;ibooks.elem[j].id) { Book temp=books.elem[i];books.elem[i]=books.elem[j];books.elem[j]=temp;} @@ -464,6 +473,7 @@ void DoSortBook() } cout << "*****************************" <>>>>>> master:code/data.h #endif // DATA_H_INCLUDED \ No newline at end of file