diff --git a/README.md b/README.md index ed9f5c2..bc3f5c0 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]() \ No newline at end of file diff --git a/code/data.h b/code/data.h index 59329a7..cbd9d6e 100644 --- a/code/data.h +++ b/code/data.h @@ -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<> 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; @@ -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 <> 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 <> 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"<> 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;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;} @@ -232,5 +241,6 @@ void DoSortBook() } cout << "*****************************" <