安徽工业大学软件工程实验报告.docx
《安徽工业大学软件工程实验报告.docx》由会员分享,可在线阅读,更多相关《安徽工业大学软件工程实验报告.docx(15页珍藏版)》请在冰豆网上搜索。
安徽工业大学软件工程实验报告
《软件工程》实验报告
姓名:
江文杰
学号:
139074333
班级:
网133
指导老师:
周兵
一.实验目的
1.能按照软件工程的思想,采用面向过程的方法开发出一个小型软件系统。
2.在软件系统开发过程中,能综合利用一门编程语言和软件工程等多门课程的知识。
3.培养良好的软件开发习惯,了解软件企业文化。
4.掌握结构化数据流分析技术。
5.掌握结构化程序设计的基本概念与技术,并且养成良好的编码风格。
6.掌握单元测试的一般步骤及技术。
7.掌握集成测试的一般步骤和技术。
二.实验容
1.软件需求分析
①、功能需求分析
·输入一个年份(1-3000),然后显示12个月的月历
·能解决闰年和平年问题
·能输出显示结果
②、运行需求分析
·操作系统:
Windows9x,Windows2000,WindowsXP及更高版本
③、数据流图
软件结构图:
2.软件设计与编码
#include
#include
#include
#include
#definefirstdayof11
/*定义第一年的第一天,星期日=7*/
#definegap""
/*setgapbetweennumbersofdates*/
#definedent""
/*setrightmargin.*/
structinfo{
intmonth;
intfirstdayofmonth;
intdaysofmonth;
intleap;
}monthinfo;
intcheckinput(void);
intinputyear(void);
intisleap(inty);
voidoutput(structinfo);
voidprinthead(structinfo);
voidprintmonth(structinfo);
structinfosetinit(int);
structinfosetmonthinfo(structinfo);
/*这个作用是判断年,如果是闰年,return1,否则
return0*/
intisleap(inty)
{
return((y%4==0&&y%100!
=0)||y%400==0);
}
/*Thismoduleistoacceptinputyear()andcheckifitiscorrect.ifitis
correctitreturnintyear,otherwiseaskuserreenter*/
intcheckinput(void)
{
inty;
do{
y=inputyear();
if(y<1||y>3000)
{
printf("\n输入错误!
。
\n\n");
y=0;
}
}while(y<1);
returny;
}
/*Thisfunctionistoaccepttheinputyear,ifitistheinteger,itreturns
it,otherwiseitreturn-1*/
intinputyear(void)
{
chars[80];
inti,y;
y=-1;
printf("请输入年份(1-3000):
");
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;
elseif(!
isdigit(s[i]))
returny;
}
y=atoi(s);
returny;
}
/*Thismoduleistoacceptmonthinfo,andprintthewholeyearcalender.*/
voidoutput(structinfomonthinfo)
{
charch;
do{
printhead(monthinfo);
printmonth(monthinfo);
printf("按任意键显视下一月,按Esc键退出.\n");
ch=getchar();
if(ch==27)
exit(0);
monthinfo=setmonthinfo(monthinfo);
}while(monthinfo.month<13);
}
/*Thismoduleistoacceptmonthinfo,amdprintmonthlyheadlike"一月"*/
voidprinthead(structinfomonthinfo)
{
char*ss;
printf("%s",dent);
switch(monthinfo.month)
{
case1:
ss="一月";
break;
case2:
ss="二月";
break;
case3:
ss="三月";
break;
case4:
ss="四月";
break;
case5:
ss="五月";
break;
case6:
ss="六月";
break;
case7:
ss="七月";
break;
case8:
ss="八月";
break;
case9:
ss="九月";
break;
case10:
ss="十月";
break;
case11:
ss="十一月";
break;
case12:
ss="十二月";
}
printf("%s%s%s%s\n\n",gap,gap,gap,ss);
}
/*Thismoduleistoacceptmonthinfo,andprintthenumbereddatesofthe
month.*/
voidprintmonth(structinfomonthinfo)
{
inti,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{
printf("%s",gap);
}
k=monthinfo.firstdayofmonth;
for(j=1;j<=monthinfo.daysofmonth;j=j+1)
{
if(k>7)
{
k=k-7;
printf("\n\n%s",dent);
};
k=k+1;
printf("%2d%s",j,gap);
}
printf("\n\n");
}
/*Thismoduleistoacceptthemonthinfo,andsetthemonthinfoofnextmonth.
*/
structinfosetmonthinfo(structinfomonthinfo)
{
intm;
monthinfo.firstdayofmonth=(monthinfo.firstdayofmonth+\
monthinfo.daysofmonth-1)%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;
}
returnmonthinfo;
}
/*Thismoduleistoinitializethemonthinfo.*/
structinfosetinit(intyear)
{
inti,days,total;
structinfomonthinfo;
monthinfo.month=1;
monthinfo.firstdayofmonth=firstdayof1;
for(i=1;i{
if(isleap(i))
days=366;
else
days=365;
monthinfo.firstdayofmonth=(monthinfo.firstdayofmonth+days-1)%7+1;
}
monthinfo.daysofmonth=31;
monthinfo.leap=isleap(year);
returnmonthinfo;
}
voidmain(){
printf("\t\t************************************\n");
printf("\t\t欢迎使用万年历演示程序\n");
printf("\t\t************************************\n");
intyear;
structinfomonthinfo;
year=checkinput();
monthinfo=setinit(year);
output(monthinfo);
}
3.单元测试
白盒测试
②.黑盒测试
2015年
三月四月
五月六月
2016年:
三.总结和体会
本次用C语言编写的万年历系统主要实现了年历、月历、日历的显示。
我根本就不喜欢敲代码了,看见代码就头疼。
所以感觉厌恶这门专业,对学习也不感兴趣了。
而且,还有一件更头疼的事是在写一个简单的程序时竟然老是出错,难一点的,复杂一点的程序竟然无从下手。
但是去看程序的参考答案时都看得懂,又感觉很容易。
学了软件工程以后,我就感觉我以前的学习方法是错误的。
以前我只注重于代码,而不注重理论知识以及编程的思路,程序的架构。
以至于在些程序时没有写程序的思路,不能形成程序的架构。
只想到看脑袋里是否有与此类似的代码。
越想程序越乱,最后脑袋里一片空白。
不知道程序从哪个方面下手了。
软件工程这门课程是做软件开发的人必学的课程,通过学这门课程,程序员就会注重软件开发的理论知识,以及做项目开发的思路。
学了这门课程后你写程序就不会去盲目的去套用代码,而是理清此程序的架构以及思路。
程序该从什么时候开始,什么时候结束。
在中间需要添加什么样的功能,以完善该软件。
在设计初期,首先温习了课本容,再次熟悉了一下C语言程序,然后广泛的查找有关万年历的资料,并结合查找到的资料,整理出设计的主要思路,画出流程图,最终写出了源程序,并编译成功,在实验中,碰到了不少问题,其中包括如何获取系统时间,如何计算任意时间的时间差,这些困难,都通过查阅资料和问同学得到了解决。
当然,由于时间和能力的原因,做得还不是很完美。
在这学期的课程序设计中,收获知识的同时,还收获了阅历,收获了成熟,通过查找大量资料,请教老师,以及不懈的努力,不仅培养了独立思考、动手制作的能力,在各种其它能力上也都有了提高。
更重要的是,在课程序设计里,我们学会了很多学习的方法,知道了理论和实践的巨大差别。
而这是以后最实用的,真的是受益匪浅。
要面对社会的挑战,只有不断的学习、实践,再学习、再实践。
同时在与老师和同学的交流过程中,互动学习,将知识融会贯通。
通过自己的努力,做出了一个万年历,对以后的学习是一个莫大的鼓舞,激起了我的学习兴趣和开发创新思维。
在调试过程中主要的问题就是结果的显示问题,显示易错位。
以及函数之间调用问题。
对于这些问题,主要是翻阅书籍和在网络上寻找解决方案,以及自己亲自用找到的方法去测试,最终成功的解决了问题。
通过这次课程设计,使我对C语言了解不再停留在书面的了解,而是有了更深的理解,培养了自己的分析能力和设计能力,受益匪浅。