|
|
|
|
# 图书管理系统
|
|
|
|
|
2023年5月1日
|
|
|
|
|
杨腾泽,孙英皓,李聪颖,刘彩月
|
|
|
|
|
|
|
|
|
|
## 项目简介
|
|
|
|
|
|
|
|
|
|
本系统是自建设计项目,实现了图书管理中的借书和还书,查询书籍,以及书籍的添加、删除和显示所有书籍等功能。项目采用 C/C++ 语言编程实现,在 VS Code 集成开发环境(IDE)中用 GCC 进行编译。系统采用模块化设计,程序结构清晰,采用菜单驱动的命令行界面,操作便捷,能够用 CSV 格式读取和保存数据,通用性强,能够用图表展示数据,直观清楚。
|
|
|
|
|
下载地址: https://bdgit.educoder.net/pkcs2aq9m/text1.git
|
|
|
|
|
项目开发过程中采用 Kanban(看板)进行任务管理和分工协作,并使用 Git 对程序代码和文档进行版本管理。任务分工情况如下:
|
|
|
|
|
|任务 |设计 |开发 |测试 |文档 |
|
|
|
|
|
|------ |-------|-------|--------|-------|
|
|
|
|
|
|Ca-Cb | | | | 孙英皓 |
|
|
|
|
|
|C0-C2 | | | | 杨腾泽 |
|
|
|
|
|
|C3-C5 | | | | 刘彩月 |
|
|
|
|
|
|C6-C8 | | | | 李聪颖 |
|
|
|
|
|
|
|
|
|
|
每个成员的工作量(百分比):
|
|
|
|
|
|杨腾泽|孙英皓|李聪颖|刘彩月|
|
|
|
|
|
|-----|----|-----|-----|
|
|
|
|
|
| 0 | 0 | 0 | 0 |
|
|
|
|
|
|
|
|
|
|
## 关于图书管理系统
|
|
|
|
|
设计一个图书管理系统,要求采用命令行菜单界面进行交互,具备查书、借书、还书、打印书籍 、添加、删除等基本功能,能够以表格和图表形式展示数据,采用 CSV 格式保存数据。
|
|
|
|
|
|
|
|
|
|
\
|
|
|
|
|
系统的功能性需求:
|
|
|
|
|
- 数据的查书、借书、还书、打印书籍、添加、删除展示。
|
|
|
|
|
|
|
|
|
|
系统的非功能性需求:
|
|
|
|
|
- 菜单驱动的命令行交互界面。
|
|
|
|
|
|
|
|
|
|
## 需求分析
|
|
|
|
|
分析系统的功能需求和界面需求,编制用户手册如下。
|
|
|
|
|
### Ca: 启动程序
|
|
|
|
|
命令行中执行命令,系统启动,显示提示信息,然后显示功能菜单,等待用户输入命令。
|
|
|
|
|
```
|
|
|
|
|
*******图书管理系统启动*******
|
|
|
|
|
————————————————————————————————————————————
|
|
|
|
|
| 1 查书 | 2 借书 | 3 还书 | 4 打印 | 5 添加 |
|
|
|
|
|
| 6 删除 | 7 修改 | 8 排序 | 0 退出 |
|
|
|
|
|
————————————————————————————————————————————
|
|
|
|
|
请选择:
|
|
|
|
|
```
|
|
|
|
|
### Cb: 显示命令菜单
|
|
|
|
|
```
|
|
|
|
|
————————————————————————————————————————————
|
|
|
|
|
| 1 查书 | 2 借书 | 3 还书 | 4 打印 | 5 添加 |
|
|
|
|
|
| 6 删除 | 7 修改 | 8 排序 | 0 退出 |
|
|
|
|
|
————————————————————————————————————————————
|
|
|
|
|
请选择:
|
|
|
|
|
```
|
|
|
|
|
### C0: 退出程序
|
|
|
|
|
选择菜单命令:0 再输入:y,确认,则退出程序。若输入:n,则继续程序。
|
|
|
|
|
```
|
|
|
|
|
请选择:0
|
|
|
|
|
确定要退出吗?(Y/N): y
|
|
|
|
|
程序退出
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
请选择:0
|
|
|
|
|
确定要退出吗?(Y/N): n
|
|
|
|
|
程序退出
|
|
|
|
|
```
|
|
|
|
|
### C1: 查找图书
|
|
|
|
|
选择菜单命令: 1 ,提示Find Book 和 Enter book ID: 字样,则继续输入图书编号。若没找到,提示Not found;若找到,提示Found 并 打印书籍信息。
|
|
|
|
|
```
|
|
|
|
|
请选择:1
|
|
|
|
|
|
|
|
|
|
Find Book
|
|
|
|
|
|
|
|
|
|
Enter book ID: 1
|
|
|
|
|
Not found
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
请选择:1
|
|
|
|
|
|
|
|
|
|
Find Book
|
|
|
|
|
|
|
|
|
|
Enter book ID: 1
|
|
|
|
|
Found
|
|
|
|
|
************
|
|
|
|
|
Book
|
|
|
|
|
|
|
|
|
|
**************** id: 1 ****************
|
|
|
|
|
**** title: 《 2 》****
|
|
|
|
|
************** Number: 3 **************
|
|
|
|
|
```
|
|
|
|
|
### C2:借用图书
|
|
|
|
|
选择菜单命令:2,提示Boorow Book和Which book you wanna boorow ?,则继续输入图书编号。若该书本身不存在,则提示NOT FOUND THIS BOOK;如图书存在,则提示OK。
|
|
|
|
|
```
|
|
|
|
|
请选择:2
|
|
|
|
|
|
|
|
|
|
Boorow Book
|
|
|
|
|
|
|
|
|
|
Which book you wanna boorow ?
|
|
|
|
|
2
|
|
|
|
|
|
|
|
|
|
NOT FOUND THIS BOOK
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
请选择:2
|
|
|
|
|
|
|
|
|
|
Boorow Book
|
|
|
|
|
|
|
|
|
|
Which book you wanna boorow ?
|
|
|
|
|
1
|
|
|
|
|
|
|
|
|
|
*********
|
|
|
|
|
OK
|
|
|
|
|
*********
|
|
|
|
|
```
|
|
|
|
|
### C3:归还图书
|
|
|
|
|
选择菜单命令:3 提示归还图书 和 你想要归还哪一本书?输入图书编号,若在系统中没有该图书,则添加图书并输入图书的编号,数量和数目,显示相关信息并归还成功,否则直接退出。
|
|
|
|
|
`````
|
|
|
|
|
请选择:3
|
|
|
|
|
|
|
|
|
|
Repaid Book
|
|
|
|
|
|
|
|
|
|
Which book you wanna repaid ?
|
|
|
|
|
2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Add Book
|
|
|
|
|
|
|
|
|
|
ID : 1
|
|
|
|
|
TITLE : 1
|
|
|
|
|
Number : 1
|
|
|
|
|
Book
|
|
|
|
|
|
|
|
|
|
**************** id: 1 ****************
|
|
|
|
|
**** title: 《 1 》****
|
|
|
|
|
************** Number: 1 **************
|
|
|
|
|
`````
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
`````
|
|
|
|
|
请选择:3
|
|
|
|
|
|
|
|
|
|
Repaid Book
|
|
|
|
|
|
|
|
|
|
Which book you wanna repaid ?
|
|
|
|
|
1
|
|
|
|
|
`````
|
|
|
|
|
|
|
|
|
|
### C4:打印书籍
|
|
|
|
|
选择菜单命令:4 提示打印书籍并打印图书信息,若没有书,则输出Total: 0 books,若有书,则输出书籍信息
|
|
|
|
|
```
|
|
|
|
|
请选择:4
|
|
|
|
|
|
|
|
|
|
Print All Books
|
|
|
|
|
|
|
|
|
|
Total: 0 books
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
请选择:4
|
|
|
|
|
|
|
|
|
|
Print All Books
|
|
|
|
|
|
|
|
|
|
Book
|
|
|
|
|
|
|
|
|
|
**************** id: 6 ****************
|
|
|
|
|
**** title: 《 6 》****
|
|
|
|
|
************** Number: 6 **************
|
|
|
|
|
|
|
|
|
|
Total: 1 books
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### C5:添加图书
|
|
|
|
|
选择菜单命令:5 提示添加图书,提示输入想添加的图书编号,标题和数目并输出Book,输出添加完后图书的相关信息和“Added”。
|
|
|
|
|
```
|
|
|
|
|
请选择:5
|
|
|
|
|
|
|
|
|
|
Add Book
|
|
|
|
|
|
|
|
|
|
ID : 1
|
|
|
|
|
TITLE : 4
|
|
|
|
|
Number : 6
|
|
|
|
|
Book
|
|
|
|
|
|
|
|
|
|
**************** id: 1 ****************
|
|
|
|
|
**** title: 《 4 》****
|
|
|
|
|
************** Number: 6 **************
|
|
|
|
|
|
|
|
|
|
*******Added********
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### C6:删除书籍
|
|
|
|
|
选择菜单命令:6 提示删除书籍、你想要删除哪本书籍?和请输入图书编号,则输入图书编号。若找到输出书籍的信息并提示Delele,若没找到则提示Not Found.
|
|
|
|
|
```
|
|
|
|
|
请选择:6
|
|
|
|
|
|
|
|
|
|
Delete Book
|
|
|
|
|
|
|
|
|
|
Which book you wanna delelet?
|
|
|
|
|
Enter book ID: 4
|
|
|
|
|
Book
|
|
|
|
|
|
|
|
|
|
**************** id: 4 ****************
|
|
|
|
|
**** title: 《 4 》****
|
|
|
|
|
************** Number: 4 **************
|
|
|
|
|
|
|
|
|
|
************************
|
|
|
|
|
Deleted
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
请选择:6
|
|
|
|
|
|
|
|
|
|
Delete Book
|
|
|
|
|
|
|
|
|
|
Which book you wanna delelet?
|
|
|
|
|
Enter book ID: 5
|
|
|
|
|
Not found
|
|
|
|
|
```
|
|
|
|
|
### C7:修改图书
|
|
|
|
|
选择菜单命令: 7,提示修改和输入图书编号,输入图书编号,再次提示图书数量,输出你要在该图书编号下修改的图书数量,并提示完成;如果输入的图书编号不存在,则提示没有这样的书。
|
|
|
|
|
`````
|
|
|
|
|
请选择:7
|
|
|
|
|
|
|
|
|
|
Revise Book
|
|
|
|
|
|
|
|
|
|
Which book you wanna revise ?
|
|
|
|
|
1
|
|
|
|
|
Original book number : 1
|
|
|
|
|
Revised number :2
|
|
|
|
|
**********************
|
|
|
|
|
Revise success
|
|
|
|
|
`````
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
``````
|
|
|
|
|
请选择:7
|
|
|
|
|
|
|
|
|
|
Revise Book
|
|
|
|
|
|
|
|
|
|
Which book you wanna revise ?
|
|
|
|
|
2
|
|
|
|
|
No such book
|
|
|
|
|
``````
|
|
|
|
|
|
|
|
|
|
# 概要设计
|
|
|
|
|
系统主要分为用户界面和数据处理两大模块。
|
|
|
|
|
|
|
|
|
|
用户界面模块包括系统初始化(init),显示菜单(display_menu),选择菜单命令
|
|
|
|
|
(make_choice)、确认(confirm)、退出(quit)等子模块。
|
|
|
|
|
数据处理模块包括 添加图书( DoAddBook ) 、查找图书( DoFindBook ) 、删除图书( DoDeleteBook ) 、打印所有图书( DoPrintBook ) 、归还图书( DoRepaidBook ) 、借用图书 ( DoBoorowBook ) 、修改图书( DoReviseBook ) 、排序图书( DoSortBook )等子模块。
|
|
|
|
|
|
|
|
|
|
其中查询、添加、修改和删除数据还会用到根据编号查询数据的方法(find)。
|
|
|
|
|
上述各模块通过主程序(main)进行调用,系统模块图如下。
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
各模块的主要功能如下:
|
|
|
|
|
## main
|
|
|
|
|
系统主函数模块,显示菜单,根据用户选择的菜单命令,执行相关操作。
|
|
|
|
|
## init
|
|
|
|
|
系统初始化。
|
|
|
|
|
## display_menu
|
|
|
|
|
显示菜单命令。
|
|
|
|
|
# 详细设计
|
|
|
|
|
针对概要设计
|
|
|
|
|
## main
|
|
|
|
|
```
|
|
|
|
|
Step 1: 初始化
|
|
|
|
|
Step 2: 根据用户选择的命令执行对应的操作
|
|
|
|
|
Step 2.1: 显示菜单
|
|
|
|
|
Step 2.2: 选择菜单命令 c
|
|
|
|
|
Step 2.3: if c == CMD_PRINT then 打印数据
|
|
|
|
|
Step 2.4:
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## DoAddBook
|
|
|
|
|
```
|
|
|
|
|
Step 1: if 数据库满 then 提示数据库满并结束
|
|
|
|
|
Step 2: 输入图书编号
|
|
|
|
|
Step 3: 输入图书名和书籍数量
|
|
|
|
|
Step 4: 添加新书籍
|
|
|
|
|
Step 5: 提示添加成功
|
|
|
|
|
```
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```
|