




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、软件工程导论题目:图书管理系统文档名称:编码设计班级:科技0801项目组长:唐子龙项目成员:唐子龙(05082019)朱磊(05082025)赵欣(05082023)刘华琛(05082004)编码设计1.根本任务依据软件工程的基本原理,详细设计阶段的根本任务是确定应该怎样具体实现所要求的系统,也就是说,经过这个阶段的设计工作,应该得出对目标系统的精确描述,具体来说就是把经过总体设计得到的各个模块详细的加以描述。2、总体设计需求概述录入功能: 输入相关数据浏览功能: 以列表方式列出所有记录信息信息查询功能: 根据书名匹配查询,并将查询结果列出借出归还功能: 根据借出与归还的书籍信息修改相应数据插
2、入与删除功能:插入一条新的图书信息,删除某图书的信息信息的备份与读入功能:将输入文件进行备份和从指定文件读入数据设置访问权限功能:只有输入正确密码才可以进行操作 否则无权操作系统结构图3、程序描述m1身份验证功能:验证身份性能:输入项:预设密码输出项:欢迎语句算法: int keyword=111,a; printf(please input keyword:); scanf(%d,&a); if(a!=keyword) exit(0); else printf(welcome!);测试要求:运行正常。m2主菜单模块功能:选择功能性能:输入项:数字0-9输出项:对应功能项算法: int dis
3、play_mainmenu() /*显示菜单的函数*/char x; do system(cls); printf(*n); printf(1.create booklistn); printf(2.display all booksn); printf(3.insert a bookinformationn); printf(4.delete a bookn); printf(5.borrow a bookn); printf(6.return a bookn); printf(7.queryn); printf(8.add records from a filen); printf(9.w
4、rite to a filen); printf(0.goodbyen); printf(*n); printf(please choose from 0-9:); printf(n); x=getchar(); while(x9); return(x-0);测试要求:运行正常。m3插入模块功能:插入新信息性能:输入项:书名 数量输出项:成功提示算法: book *insert(book *head,book *s) /*插入结点的函数*/ book *p0,*p1,*p2; p1=head;p0=s; /*使p1指向第一个结点,p0指向要插入的结点*/ if(head=null) /*原来的
5、链表是空表*/ head=p0;p0-next=null; /*使p0作为首结点*/ while(strcmp(p0-name,p1-name)0&(p1-next!=null) p2=p1; p1=p1-next; if(strcmp(p0-name,p1-name)next=p1; if(head=p1) head=p0; else p2-next=p0; elsep1-next=p0;p0-next=null; return(head);book *insert_a_record(book *head) book *newrecord; newrecord=(book *)malloc(
6、len); /*动态分配存储空间*/ scanf(%s%d,newrecord-name,&newrecord-all); newrecord-borrow=0; newrecord-left=newrecord-all; head=insert(head,newrecord); printf(insert successfullyn); /*输出插入成功的信息*/ return(head);测试要求:运行正常。删除模块功能:删除信息性能:输入项:所删书名输出项:成功提示算法: book *delete(book *head,char *name) book *p1,*p2; if(head=
7、null) printf(sorry no record!n); p1=head; while(strcmp(p1-name,name)!=0&p1-next!=null) /*p1不是要找的结点,且后面还有结点*/ p2=p1;p1=p1-next; /*p1后移一个结点*/ if(strcmp(p1-name,name)=0) /*找到了*/ if(p1=head)head=p1-next; /*若p1为首指针,使下一结点为首指针*/ else p2-next=p1-next; /*否则将下一结点地址赋给前一结点地址*/ printf(delete %s successfullyn,nam
8、e); /*输出删除成功的信息*/ return(head);book *delete_a_record(book *head) char name20,ch; book *p; scanf(%s,name); getchar(); /*接收回车*/ p=query(head,name); if(p=null) printf(cannot find %sn,name); /*找不到结点*/ else printf(delete %s, y/n?n,name); ch=getchar(); system(pause); if(ch=y|ch=y) while(p!=null) head=dele
9、te(head,name); /*删除所有与输入相同的记录*/ p=query(head,name); return(head);测试要求:运行正常。m5查询模块功能: 查询功能性能:输入项:查询书名输出项:相应书籍信息算法: book *query(book *head,char *name) book *p; p=head; while(strcmp(name,p-name)!=0&p-next!=null) p=p-next; if(strcmp(name,p-name)=0) /*找到了,返回结点地址*/ return(p); else /*找不到返回空指针*/ return(null
10、);void query_a_record(book *head) char name20; book *p; scanf(%s,name); p=query(head,name); if(p!=null) /*找到了*/ printf(find successfullyn%s total:%d left:%d borrow:%dn, p-name,p-all,p-left,p-borrow); else printf(cant find the records of %sn,name); /*找不到*/测试要求:运行正常。m6显示功能功能: 显示所有信息性能:输入项:相应的菜单序号输出项:所
11、有书籍信息算法: void display(book *head) book *p; int i; p=head; printf(num bookname total left borrown); for(i=1;p!=null;i+) printf(%-5d%-14s%-10d%-10d%-5dn, i,p-name,p-all,p-left,p-borrow); p=p-next; if(i%10=0) system(pause); /*按回车翻页显示*/ printf(num bookname total left borrown); 测试要求:运行正常。m7借出模块功能:借出书籍性能:
12、输入项:所借书名 数量输出项:成功信息算法: book *borrow_a_book(book *head) char name20,ch; int n; book *p; scanf(%s%d,name,&n); getchar(); /*接收回车*/ p=query(head,name); if(p=null) printf(cannot find %sn,name); /*找不到结点*/ else printf(are you sure to borrow? %s, y/n?n,name); ch=getchar(); system(pause); if(ch=y|ch=y) head=
13、borrow(head,name,n); return(head);测试要求:运行正常。m8归还模块功能:归还书籍性能:输入项:所换书名 数量输出项:成功提示算法: book *return_a_book(book *head) char name20,ch; int n; book *p; scanf(%s%d,name,&n); getchar(); /*接收回车*/ p=query(head,name); if(p=null) printf(cannot find %sn,name); /*找不到结点*/ else printf(are you sure to return? %s, y
14、/n?n,name); ch=getchar(); system(pause); if(ch=y|ch=y) head=return(head,name,n); return(head);book *return(book *head,char *name,int sum) book *p1; p1=head; while(strcmp(p1-name,name)!=0&p1-next!=null) /*p1不是要找的结点,且后面还有结点*/ p1=p1-next; /*p1后移一个结点*/ if(strcmp(p1-name,name)=0) /*找到了*/ p1-borrow=p1-bor
15、row-sum; p1-left=p1-left+sum; return(head);测试要求:运行正常。m9读入模块功能:从文件读入信息性能:输入项:文件名输出项:成功提示算法: book *addfromtext(book *head,char *filename) file *fp; int n,i; if(fp=fopen(filename,r)=null) printf(cannot find file:%sn,filename); /*打不开所指定文件*/ return(head); fscanf(fp,%d,&n); /*待插入记录个数*/ for(i=0;iname,&p-al
16、l,&p-left,&p-borrow); head=insert(head,p); /*插入结点*/ printf(add from %s successfullyn,filename); fclose(fp);return(head);测试要求:运行正常。m10备份模块功能:数据备份性能:输入项:所建文档名输出项:成功提示算法: book *writetotext(book *head,char *filename)file *fp;book *p; if(head=null) printf(no record!n); return(head); fp=fopen(filename,w);
17、 /*打开文件*/ p=head; while(p!=null) fprintf(fp,%-14s%-10d%-10d%-10dnn,p-name,p-all,p-left,p-borrow); /*文件输出*/ p=p-next; printf(write to %s successfullyn,filename); /*输出写到文件完毕的信息*/ fclose(fp); return(head);测试要求:运行正常。m11退出模块功能:退出程序性能:输入项:数字0输出项:再见语句算法: void quit(book *head)book *p,*p1,*p2;file *fp; char
18、filename=last; p2=p1=head; if(head!=null) fp=fopen(filename,w); /*打开文件*/ p=head; while(p!=null) fprintf(fp,%s %d %d %dn,p-name,p-all,p-left,p-borrow); /*文件输出*/ p=p-next; printf(write to %s successfullyn,filename); /*输出写到文件完毕的信息*/ fclose(fp); while(p1!=null) /*p1指向的结点不是空指针*/ p2=p1-next; free(p1); /*释
19、放存储空间*/ p1=p2; /*p1后移一个结点*/ 测试要求:运行正常。五、测试报告1、引言编写目的:测试图书馆管理系统软件的各项功能是否符合预期要求。本报告读者为软件设计者。项目背景:该软件由学生个人设计,无开发部门和主管部门,主要供学生练习使用。该软件独立于其它软件系统。参考资料: 万晓东 施玉霞 等著软件技术基础教程09年7月 谭浩强 著c语言程序设计 第三版 张志航 王珊珊等 著程序设计语言c 07年9月2、测试计划执行情况权限功能测试数据:输入正确密111测试结果:成功进入主界面,说明本模块功能正常插入功能测试数据:无测试结果:菜单显示正常。本模块功能正常。插入功能测试数据:hi
20、story 100测试结果:调用显示函数显示结果。本模块功能正常。删除操作测试数据:history 测试结果调用显示函数显示结果:输出结果正确,说明本模块功能正常。查询模块测试数据:预输入数据 history 100 physics 200 查询history测试结果:显示结果 history 100 0 0说明本模块运行正常。显示模块上述过程已经对本功能进行了测试。结果:显示模块运行正常。借出模块测试数据:预输入数据 history 100 physics 200 调用借出函数借 history 50 maths 100测试结果 调用显示函数显示结果:归还模块测试数据:预输入数据 histo
21、ry 100 physics 200 调用归还函数还 history 50 测试结果:文件读入模块测试数据:文本文档 a.txt测试结果:调用显示函数显示结果测试结果正确。文件备份模块测试数据: 测试数据采用上一步写入的数据测试结果退出模块测试数据: 无测试结果 成功退出程序 并生自动成备份文件 last.txt 退出模块运行正常。3、评价结果软件能力: 软件各项功能复合预期,各子程序运行正常缺陷和限制:每次登陆后必须手工调入上一次的备份文件以恢复系统数据,给操作者带来不便建议: 完善系统的数据库功能,提供安全可靠的数据保存功能。测试结论: 本软件测试通过。附源程序代码:#include#in
22、clude#include#include#define null 0#define len sizeof(book)struct a char name20; int all,left,borrow; struct a *next; ;typedef struct a book;int display_main_menu(); /*主菜单显示*/book *create(); /*功能函数声明*/ void display(book *head);book *insert(book *head,book *s);book *insert_a_record(book *head);book *
23、delete(book *head,char *name);book *delete_a_record(book *head);book *borrow(book *head,char *name,int sum);book *borrow_a_book(book *head);book *return(book *head,char *name,int sum);book *return_a_book(book *head);book *query(book *head,char *name); void query_a_record(book *head);book *addfromtex
24、t(book *head,char *filename);book *writetotext(book *head,char *filename); void quit(book *head);void main() /*主函数部分*/book *head; /*定义变量*/ char filename20; int keyword=111,a; printf(please input keyword:); scanf(%d,&a); if(a!=keyword) exit(0); else printf(welcome!); head=null; /*置首指针为空*/ for(;) swit
25、ch(display_mainmenu() case 1:printf(1.create booklistn); /*调用create函数创建链表*/ head=create(); system(pause); break; case 2:printf(display all booksn); display(head); /*调用display函数显示所有*/ system(pause);break; case 3:printf(insert a recordn); head=insert_a_record(head);/*调用insert_a_record函数插入*/ system(pau
26、se);break; case 4:printf(delete a bookn); head=delete_a_record(head);/*调用delete_a_record函数删除*/ system(pause);break; case 5:printf(borrow a bookninput bookname and sum you borrow:); head=borrow_a_book(head); system(pause);break; case 6:printf(return a bookninput bookname and sum you return:); head=re
27、turn_a_book(head); system(pause);break; case 7:printf(queryninput the bookname you want:); query_a_record(head);/*调用查询函数*/ system(pause);break; case 8:printf(input the name of text filen); scanf(%s,filename);/*输入文件名*/ head=addfromtext(head,filename); system(pause);break; case 9:printf(input the name
28、 of the newtext filen); scanf(%s,filename);/*输入要写入的文件名*/ head=writetotext(head,filename); system(pause);break; case 0:printf(goodbyen); quit(head); exit(0); int display_mainmenu() /*显示菜单的函数*/char x; do system(cls); printf(*n); printf(1.create booklistn); printf(2.display all booksn); printf(3.insert
29、 a bookinformationn); printf(4.delete a bookn); printf(5.borrow a bookn); printf(6.return a bookn); printf(7.queryn); printf(8.add records from a filen); printf(9.write to a filen); printf(0.goodbyen); printf(*n); printf(please choose from 0-9:); printf(n); x=getchar(); while(x9); return(x-0);book *
30、create() /*创建链表的函数,返回首指针*/book *head,*newrecord; char ch; printf(input a bookn); head=null;/*首指针置空*/ do newrecord=(book *)malloc(len); /*动态分配存储空间*/ scanf(%s%d,newrecord-name,&newrecord-all); newrecord-left=newrecord-all; newrecord-borrow=0; head=insert(head,newrecord); /*调用insert函数判断位置插入*/ getchar()
31、; / *接收最后输入的回车符*/ printf(add another book y/n?n); ch=getchar(); getchar(); /*接收回车符*/while(ch!=n&ch!=n); /*判断是否继续*/ return(head);book *insert(book *head,book *s)/*插入结点的函数*/ book *p0,*p1,*p2; p1=head;p0=s; if(head=null) head=p0;p0-next=null; while(strcmp(p0-name,p1-name)0&(p1-next!=null) p2=p p1=p1-ne
32、xt; if(strcmp(p0-name,p1-name)next=p1; if(head=p1) head=p0; else p2-next=p0; elsep1-next=p0;p0-next=null; return(head);book *insert_a_record(book *head) book *newrecord; newrecord=(book *)malloc(len); /*动态分配存储空间*/ scanf(%s%d,newrecord-name,&newrecord-all); newrecord-borrow=0; newrecord-left=newrecor
33、d-all; head=insert(head,newrecord); printf(insert successfullyn);/*输出插入成功的信息*/ return(head);book *delete(book *head,char *name) /*删除功能函数*/ book *p1,*p2; if(head=null) printf(sorry no record!n); p1=head; while(strcmp(p1-name,name)!=0&p1-next!=null) / p2=p1;p1=p1-next; if(strcmp(p1-name,name)=0) if(p1
34、=head)head=p1-next; else p2-next=p1-next; printf(delete %s successfullyn,name); return(head);book *delete_a_record(book *head) char name20,ch; book *p; scanf(%s,name); getchar(); p=query(head,name); if(p=null) printf(cannot find %sn,name); else printf(delete %s, y/n?n,name); ch=getchar(); system(pau
35、se); if(ch=y|ch=y) while(p!=null) head=delete(head,name); p=query(head,name); return(head);book *borrow_a_book(book *head) char name20,ch; int n; book *p; scanf(%s%d,name,&n); getchar(); / p=query(head,name); if(p=null) printf(cannot find %sn,name); else printf(are you sure to borrow? %s, y/n?n,name
36、); ch=getchar(); system(pause); if(ch=y|ch=y) head=borrow(head,name,n); return(head);book *borrow(book *head,char *name,int sum) book *p1; p1=head; while(strcmp(p1-name,name)!=0&p1-next!=null) p1=p1-next; if(strcmp(p1-name,name)=0) p1-borrow=sum; p1-left=p1-all-sum; return(head);book *return_a_book(
37、book *head) char name20,ch; int n; book *p; scanf(%s%d,name,&n); getchar(); /*接收回车*/ p=query(head,name); if(p=null) printf(cannot find %sn,name); /*找不到结点*/ else printf(are you sure to return? %s, y/n?n,name); ch=getchar(); system(pause); if(ch=y|ch=y) head=return(head,name,n); return(head);book *ret
38、urn(book *head,char *name,int sum) book *p1; p1=head; while(strcmp(p1-name,name)!=0&p1-next!=null) /*p1不是要找的结点,且后面还有结点*/ p1=p1-next; /*p1后移一个结点*/ if(strcmp(p1-name,name)=0) /*找到了*/ p1-borrow=p1-borrow-sum; p1-left=p1-left+sum; return(head);void display(book *head) book *p; int i; p=head; printf(num
39、bookname total left borrown); for(i=1;p!=null;i+) printf(%-5d%-14s%-10d%-10d%-5dn, i,p-name,p-all,p-left,p-borrow); p=p-next; if(i%10=0) system(pause); /*按回车继续显示*/ printf(num bookname total left borrown); book *query(book *head,char *name) book *p; p=head; while(strcmp(name,p-name)!=0&p-next!=null) p=p-next; if(strcmp(name,p-name)=0) /*找到了,返回结点地址*/ return(p); else /*找不到返回空指针*/ re
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 客观分析CFA试题及答案
- 印度神像美术课件
- 食品安全知识宣传主题班会
- 大学生防骗知识课件下载
- 医疗器械行业的安全知识培训
- 收银基础知识
- 预防校园伤害2
- 针刺伤的预防
- 预防下肢静脉栓塞
- 大班幼儿安全教育教案
- 2025年痕迹检验考试题及答案
- 2025年安徽医学高等专科学校单招职业适应性测试题库完整版
- 《作酢法》二则教案-【中职专用】高二语文同步教学(高教版2023·拓展模块下册)
- 人教部编版道德与法治八年级下册:3.2 《依法行使权利》听课评课记录
- 机电一体化专业课程改革调研报告及改革建议
- 新生儿各种导管的护理
- 《天津天狮奖金制度》课件
- 2025年中远海运投资控股有限公司招聘笔试参考题库含答案解析
- 人力资源内部培训课件
- 医院临床医学带教老师培训
- 2024年03月浙江南浔银行春季招考笔试历年参考题库附带答案详解
评论
0/150
提交评论