《软件工程》实验报告
姓
名: : 江文杰
学
号 :1390743 33
班
级: :网 网 133
指导老师: : 周兵
一.
实验目得 1.能按照软件工程得思想,采用面向过程得方法开发出一个小型软件系统。
2.在软件系统开发过程中,能综合利用一门编程语言与软件工程等多门课程得知识。
3.培养良好得软件开发习惯,了解软件企业文化。
4.掌握结构化数据流分析技术。
5.掌握结构化程序设计得基本概念与技术,并且养成良好得编码风格。
6.掌握单元测试得一般步骤及技术。
7.掌握集成测试得一般步骤与技术。
二.
实验内容 1 . 软件需求分析
① 、功能需求分析
·输入一个年份(13000),然后显示 12 个月得月历
·能解决闰年与平年问题
·能输出显示结果 ②、运行需求分析
·
操作系统: Windows9x,
Windows2000, Windows XP 及更高版本 ③、数据流图
软件结构图:
2 . 软件设计与编码 #include <stdio、h> #include <ctype、h> #include <stdlib、h> #include <math、h> #define firstdayof1 1
/* 定义第一年得第一天, 星期日=7 */ #define gap "
"
/* set gap between numbers of dates */ #define dent "
"
/* set right margin、 */ struct info {
int month;
int firstdayofmonth;
int daysofmonth;
int leap;
}monthinfo; int checkinput(void); checkinput main output inputyear isleap
setinit setinfo printhead printmonth 检查输入 确定年份 算 计算 1 月 月 1 日 示 显示 1 月 示 显示 2 月 示 显示 12 月 显示表头 显示其她月份 错误 非法 年份 年份 年份 年份 就是否闰开始信息 开始信息 任 意键
int inputyear(void); int isleap(int y); void output(struct info); void printhead(struct info ); void printmonth(struct info); struct info setinit(int); struct info setmonthinfo(struct info ); /* 这个作用就是判断年, 如果就是闰年,
return 1, 否则
return 0
*/ int isleap(int y) {
return ((y%4==0 && y%100!=0)
|| y%400==0); } /* This module is to accept inputyear and check if it is correct、 if it is
correct it return int year, otherwise ask user reenter
*/ int checkinput(void) {
int y;
do{
y=inputyear;
if(y<1 || y >3000)
{
printf("\n 输入错误!。\n\n");
y=0;
}
}while(y<1);
return y;
} /* This function is to accept the input year, if it is the integer, it returns
it, otherwise it return 1
*/ int inputyear(void) {
char s[80];
int i, y;
y=1;
printf("请输入年份(13000):");
for(i=0;i<80;++i)
{
s[i]=getchar;
if(s[i]==27)
exit(0);
if(s[i]==10)
break;
}
for(i=0;i<80;++i)
{
if(s[i]==10) break;
else if(!isdigit(s[i]))
return y;
}
y=atoi(s);
return y; } /*This module is to accept monthinfo, and print the whole year calender、
*/ void output(struct info monthinfo) {
char ch;
do{
printhead(monthinfo);
printmonth(monthinfo);
printf("按任意键显视下一月, 按 Esc 键退出、 \n");
ch=getchar;
if(ch==27)
exit(0);
monthinfo=setmonthinfo(monthinfo);
}while(monthinfo、month<13); } /* This module is to accept monthinfo, amd print monthly head like"一
月"
*/ void printhead(struct info monthinfo) {
char *ss;
printf("%s",dent);
switch(monthinfo、month)
{
case 1:
ss="一
月";
break;
case 2:
ss="二
月";
break;
case 3:
ss="三
月";
break;
case 4:
ss="四
月";
break;
case 5:
ss="五
月";
break;
case 6:
ss="六
月";
break;
case 7:
ss="七
月";
break;
case 8:
ss="八
月";
break;
case 9:
ss="九
月";
break;
case 10:
ss="十
月";
break;
case 11:
ss="十一
月";
break;
case 12:
ss="十二
月";
}
printf("
%s%s%s%s\n\n",gap,gap,gap,ss); } /* This module is to accept monthinfo, and print the numbered dates of the
month 、
*/ void printmonth(struct info monthinfo) {
int i,j,k;
printf("%s",dent);
printf(" 一 %s 二 %s 三 %s 四 %s 五 %s 六 %s 日\n\n",gap,gap,gap,gap,gap,gap);
printf("%s",dent);
for(i=1;i<monthinfo、firstdayofmonth;i=i+1)
{
printf("%s
",gap);
}
k=monthinfo、firstdayofmonth;
for(j=1;j<=monthinfo、daysofmonth;j=j+1)
{
if(k>7)
{
k=k7;
printf("\n\n%s",dent);
};
k=k+1;
printf("%2d%s",j,gap);
}
printf("\n\n"); } /* This module is to accept the monthinfo, and set the monthinfo of next month、
*/
struct info setmonthinfo(struct info monthinfo) {
int m;
monthinfo、firstdayofmonth= (monthinfo、firstdayofmonth+ \
monthinfo、daysofmonth1)%7+1;
monthinfo、month=monthinfo、month+1;
monthinfo、daysofmonth=30;
m=monthinfo、month;
if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m ==12)
monthinfo、daysofmonth=31;
if(m==2)
{
if(monthinfo、leap)
monthinfo、daysofmonth = 29;
else
monthinfo、daysofmonth = 28;
}
return monthinfo; } /* This module is to initialize the monthinfo、 */
struct info setinit(int year) {
int i,days,total;
struct info monthinfo;
monthinfo、month=1;
monthinfo、firstdayofmonth=firstdayof1;
for(i=1;i<year;i=i+1)
{
if(isleap(i))
days=366;
else
days=365 ;
monthinfo 、 firstdayofmonth=(monthinfo 、firstdayofmonth+days1)%7+1;
}
monthinfo、daysofmonth=31;
monthinfo、leap=isleap(year);
return monthinfo; } void main{ printf("
\t\t************************************
\n");
printf("
\t\t 欢 迎 使 用 万 年 历 演 示 程 序
\n");
printf("
\t\t************************************
\n");
int year ;
struct info monthinfo;
year = checkinput;
monthinfo = setinit(year);
output(monthinfo); } 3 . 单元测试
白盒测试
② ②. 黑盒测试 2015 年
三月四月
五月六月
2016 年:
三.
总结与体会 用 本次用 C 语言编写得万年历系统主要实现了年历、月历、日历得显示。我根本就不喜欢敲代码了, 瞧见代码就头疼。所以感觉厌恶这门专业 业, 对学习也不感兴趣了。而且, 还有一件更头疼得事就是在写一个简单得程序时竟然老就是出错, 难一点得,复 复懂 杂一点得程序竟然无从下手。但就是去瞧程序得参考答案时都瞧得懂, 又感觉很容易。学了软件工程以后, 我就感觉我以前得学习方法就是错误得。以前我只注重于代码 码, 而不注重理论知识以及编程得思路, 程序得架构。以至于在些程序时没有写程序得思路, 不能形成程序得架构。只想到瞧脑袋里就是否有与此类似得代码。越想程序越乱 乱, 最后脑袋里一片空白。不知道程序从哪个方面下手了。软件工程这门课程就是做软件开发得人必学得课程, 通过学这门课程,程 程 序员就会注重软件开发得理论知识,以 以及做项目开发得思路。学了这门课程后您写程序就不会去盲目得去套用代码, 而就是
理清此程序得架构以及思路。程序该从什么时候开始, 什么时候结束。在中间需要添加什么样得功能, 以完善该软件。
在设计初期, 首先温习了课本内容, 再次熟悉了一下 C 语言程序, 然后广泛得查找有关万年历得资料, 并结合查找到得资料, 整理出设计得主要思路, 画出流程图, 最终写出了源程序, 并编译成功, 在实验中, 碰到了不少问题, 其中包括如何获取系统时间,如 如何计算任意时间得时间差, 这些困难, 都通过查阅资料与问同学得到了解决。当然 然,由 由于时间与能力得原因, 做得还不就是很完美。
在这学期得课程序设计中, 收获知识得同时, 还收获了阅历, 收获了成熟, 通过查找大量资料, 请教老师, 以及不懈得努力, 不仅培养了独立思考、 动手制作得能力, 在各种其它能力上也都有了提高。更重要得就是, 在课程序设计里, 我们学会了很多学习得方法 法, 知道了理论与实践得巨大差别。而这就是以后最实用得, 真得就是受益匪浅。要面 对社会得挑战, 只有不断得学习、实践, 再学习、再实践。同时在与老师与同学得交流过程中, 互动学习, 将知识融会贯通。通过自己得努力, 做出了一个万年历, 对以后得学习 就是一个莫大得鼓舞, 激起了我得学习兴趣与开发创新思维。
在调试过程中主要得问题就就是结果得显示问题, 显示易错位。以及函数之间调用问题。对于这些问题, 主要就是翻阅书籍与在网络上寻找解决方案, 以及自己亲自用找到得方法去测试, 最终成功得解决了问题。
通过这次课程设计,对 使我对 C 语言了解不再停留在书面得了解, 而就是有了更深得理解, 培养了自己得分析能力与设计能力, 受益匪浅。
版权所有:格斯文档网 2010-2024 未经授权禁止复制或建立镜像[格斯文档网]所有资源完全免费共享
Powered by 格斯文档网 © All Rights Reserved.。浙ICP备19042928号