软件工程课程设计报告 王文生.docx

上传人:b****3 文档编号:26697205 上传时间:2023-06-21 格式:DOCX 页数:29 大小:383.99KB
下载 相关 举报
软件工程课程设计报告 王文生.docx_第1页
第1页 / 共29页
软件工程课程设计报告 王文生.docx_第2页
第2页 / 共29页
软件工程课程设计报告 王文生.docx_第3页
第3页 / 共29页
软件工程课程设计报告 王文生.docx_第4页
第4页 / 共29页
软件工程课程设计报告 王文生.docx_第5页
第5页 / 共29页
点击查看更多>>
下载资源
资源描述

软件工程课程设计报告 王文生.docx

《软件工程课程设计报告 王文生.docx》由会员分享,可在线阅读,更多相关《软件工程课程设计报告 王文生.docx(29页珍藏版)》请在冰豆网上搜索。

软件工程课程设计报告 王文生.docx

软件工程课程设计报告王文生

福建农林大学计算机与信息学院

计算机类

 

课程设计报告

课程名称:

软件工程导论

课程设计题目:

学生通讯录

姓名:

王文生

系:

软件工程

专业:

软件工程

年级:

11

学号:

3116016025

指导教师:

黄世国

职称:

副教授

 

2013年5月30日

 

福建农林大学计算机与信息学院计算机类

课程设计结果评定

评语:

成绩:

指导教师签字:

任务下达日期:

评定日期:

目录

 

1.需求分析3

2.1系统特点5

2.2设计内容5

2.21结构图5

2.22核心算法6

3.人机界面设计11

3.1主界面11

4、编码实现12

5.软件测试25

5.1添加联系人25

5.2查找联系人26

5.3删除并显示联系人26

5.4修改联系人27

6.心得和总结27

7.参考文献28

 

1.需求分析

1.1课程需求分析

随着通讯工具的逐渐普及,以及人际关系的范围扩大,人们需要一个通讯录管理系统帮忙记住亲朋的通讯方式。

本课程设计为学生通讯录,主要是为教师服务的,当今教育的普及,使得一位教师必须得管理数量较多的学生,而教师不可能记住每位学生的联系方式,这就必须通过一个系统平台进行管理。

并且学生在学校有特定的学号,便可以通过学号为导向对学生的联系方式进行存储。

本通讯录适合经常使用电脑的用户,可以作为一种储存软件和备份软件,软件占内存小,安装简单,性能稳定,独有的文本存档可以支持直接点击文件查看方式,当然也可以通过软件显示,程序兼容性强,转移方便,是一款综合性,时代性,人性化的软件。

1.2系统需求分析

任务说明:

能设计并建立一个通讯录

能精确查询

能模糊查询

能够修改通讯录中的信息

能够增加和删除通讯录中内容

将通讯录中内容保存到文件中,并能正确读取

在程序运行正确的前提下,优化算法

 

主体实现步骤:

创建通讯录

增加用户信息

显示用户信息

精确查询你需要的用户信息

模糊查询你需要的用户信息

修改你要更新的用户信息

删除你不需要的用户信息

修改通讯录的密码

退出通讯录程序

 

2、设计

2.1系统特点

本设计提供了通讯录的相关操作

1.添加联系人:

按提示输入联系人的姓名,学号,手机号,qq号,以文件形式进行保存;

2.查找联系人:

提供按学号和姓名两种查找方式,并从已存信息文件中读出,显示给用户;

3.删除联系人:

用户输入需要修改的联系人姓名或学号,从文件中读出信息,并将联系人的信息

删除,后再保存于文件中;

4.修改联系人:

用户输入需要修改的联系人姓名,并按提示输入需要修改的信息,修还确认之后,

保存于文件中;

5.显示联系人:

对文件内保存的联系人进行排序,提供学号和姓名排序两种排序方式,姓名排序按

姓氏拼音首字母排序,排序完之后显示给用户。

2.2设计内容

2.21结构图

函数层次结构图:

2.22核心算法

//修改联系人

inttongxunlu:

:

xiugai()

{

intn=0;

ifstreamifile;

ofstreamofile;

ofile.open("temp.txt",ios:

:

out);

ifile.open("tongxunlu.txt",ios:

:

in);

if(!

ofile||!

ifile)

{

cout<

"<

return0;

}

stringname2;

cout<<"请输入您要修改的学生的姓名:

\t";

cin>>name2;

while(!

ifile.eof())

{

ifile>>name>>number>>phone>>qq;

if(name==name2)

{

cout<<"您要修改的人是:

\n";

cout<

n=1;

}

else

ofile<

}

if(n==0)

{

cout<<"您要修改的学生本来就不存在!

请检查重新输入!

"<

return0;

}

stringnam,num,q,pho;

cout<<"姓名:

";cin>>nam;

cout<<"学号:

";cin>>num;

cout<<"电话号码:

";cin>>pho;

cout<<"qq号码:

";cin>>q;

cout<

ofile<

ifile.close();

ofile.close();

ofstreamout("tongxunlu.txt",ios:

:

out|ios:

:

trunc);

ifstreamin("temp.txt",ios:

:

in);

while(!

in.eof())

{

in>>name>>number>>phone>>qq;

out<

}

out.close();

in.close();

system("pause");

return0;

}

//对联系人排序

inttongxunlu:

:

paixu()

{

system("cls");

intk,x;

tongxunlup[100];

fstreamfile;

intn=0;

tongxunlutemp;

ifstreamifile;

ofstreamofile;

ofile.open("temp.txt",ios:

:

out);

ifile.open("tongxunlu.txt",ios:

:

in);

if(!

ofile||!

ifile)

{

cout<

"<

return0;

}

while(!

ifile.eof())

{

ifile>>name>>number>>phone>>qq;

p[n].name=name;p[n].number=number;p[n].phone=phone;p[n].qq=qq;

n++;

}

n=n-1;

cout<<"\n\n\t1.按学号显示\n\t2.按姓名显示\n\t请选择排序方式:

";

cin>>x;

if(x==1)

{

for(k=1;k<=n;k++)

for(intj=0;j

if(p[j].number>p[j+1].number)

{

temp=p[j];

p[j]=p[j+1];

p[j+1]=temp;

}

cout<<"\n\t按学号方式排序"<

}

elseif(x==2)

{

for(k=1;k<=n;k++)

for(intj=0;j

if(p[j].name>p[j+1].name)

{

temp=p[j];

p[j]=p[j+1];

p[j+1]=temp;

}

cout<<"\n\t按姓名方式排序"<

}

else

{

cout<<"\n\t未选择排序方式,默认按文件里的顺序显示"<

system("pause");

return0;}

ofstreamout("tongxunlu.txt",ios:

:

out|ios:

:

trunc);

ifstreamin("temp.txt",ios:

:

in);

for(k=0;k<=n;k++)

{

in>>name>>number>>phone>>qq;

out<

}

out.close();

in.close();

system("pause");

return0;

}

3.人机界面设计

3.1主界面:

主界面分析:

主界面显示颜色为蓝色,给人清新之感。

再者,本系统主要针对教师而设计,所以在主界面添加入“春蚕到死丝方尽,蜡炬成灰泪始干”语句,主界面排列整齐规范,输入提醒人性化。

3.2功能分析:

3.2.1学号运用

本系统除了一般通讯录的功能以外,还设计了学号查找和排序功能,学生在学校主要以学号为依据,这样更能给教师对于本系统的运用带来很大的遍历之处。

3.2.2文件储存

运用文件储存通讯录信息,保证了用户创建的信息不会丢失,同时用户可以通过修改txt文件里的内容,载入系统中运用,很大程度上为用户提供的便利。

4、编码实现

源代码:

#include

#include

#include

#include

#include

#include

usingnamespacestd;

voidcaidan();//菜单

classziliao

{

public:

stringname;

stringnumber;

};

classlianxi

{

public:

stringphone;

stringqq;

};

 

classtongxunlu:

virtualpublicziliao,virtualpubliclianxi

{

public:

voidzengtian();//增添联系人

voidchaxun();//查询联系人

voidshanchu();//删除联系人

intxiugai();//修改联系人

voidxianshi();//显示联系人

intpaixu();//按学生姓名首字母输出

};

 

//显示联系人

voidtongxunlu:

:

xianshi()

{

fstreamtxl;

txl.open("tongxunlu.txt",ios:

:

in);

if(!

txl)

cout<<"对不起,打开文件失败!

"<

else

{

system("cls");

cout<<"\n\t============================================================"<

cout<<"\t||姓名|学号|手机号|QQ号||"<

txl>>name;

while(!

txl.eof())

{

txl>>number>>phone>>qq;

cout<<"\t||"<

txl>>name;

}

cout<<"\t============================================================"<

}

system("pause");

txl.close();

}

//增添联系人

voidtongxunlu:

:

zengtian()

{

cout<<"请根据提示输入联系人信息:

"<

cout<<"学生姓名:

";cin>>name;

cout<<"学生学号:

";cin>>number;

cout<<"学生手机号:

";cin>>phone;

cout<<"学生QQ号:

";cin>>qq;

fstreamtxl;

txl.open("tongxunlu.txt",ios:

:

out|ios:

:

app);

if(!

txl)

cout<<"对不起,打开文件失败!

"<

else

{

txl<

:

left)

<

<

<

<

}

txl.close();

cout<<"新添加的联系人的信息已经保存完毕!

"<

system("pause");

}

//查询

voidtongxunlu:

:

chaxun()

{

fstreamtxl;

txl.open("tongxunlu.txt",ios:

:

in);

if(!

txl)

cout<

"<

else

{

intjudge1=0,judge2=0;

inti;

cout<<"请输入您要查询的方式:

"<

<<"1--按学生姓名查询"<

<<"2--按学生学号查询"<

cin>>i;

stringname1,number1;

if(i==1)

{

cout<<"请输入您要查询的学生的姓名:

";

cin>>name1;

while(!

txl.eof())

{

txl>>name>>number>>phone>>qq;

if(name1==name)

{

cout<<"姓名"<<"\t"<<"学号"<<"\t\t"<<"手机号"<<"\t\t"<<"QQ号"<

cout<

judge1=1;

break;

}

}

if(judge1==0)

cout<<"对不起,您输入错误!

"<

}

elseif(i==2)

{

cout<<"请输入您要查询的学生的学号:

";

cin>>number1;

while(!

txl.eof())

{

txl>>name>>number>>phone>>qq;

if(number1==number)

{

cout<<"姓名"<<"\t"<<"学号"<<"\t\t"<<"手机号"<<"\t\t"<<"QQ号"<

cout<

judge2=1;

break;

}

}

if(judge2==0)

cout<<"对不起,您输入错误!

"<

}

}

system("pause");

txl.close();

}

//删除联系人

voidtongxunlu:

:

shanchu()

{

ofstreamOUT("temp.txt",ios:

:

out);

ifstreamIN("tongxunlu.txt",ios:

:

in);

if(!

OUT||!

IN)

{

cout<

"<

return;

}

stringsign;

cout<

";

cin>>sign;

boolflag=true;

stringstr;

while(IN>>name>>number)

{

getline(IN,str);

if((sign==name)||(sign==number))

{

cout<

"<

cout<

:

left)<

<<""<

flag=false;

break;

}

OUT<

:

left)<

<<""<

}

if(flag)

{

cout<

!

!

联系人中没你找的人!

!

!

!

"<

}

else

{

while(getline(IN,str))

{

OUT<

}

OUT.close();

IN.close();

ofstreamout("tongxunlu.txt",ios:

:

out);

ifstreamin("temp.txt",ios:

:

in);

if(!

out||!

in)

{

cout<

"<

return;

}

while(getline(in,str))

{

out<

}

out.close();

in.close();

cout<

!

!

"<

}

system("pause");

}

//修改联系人

inttongxunlu:

:

xiugai()

{

intn=0;

ifstreamifile;

ofstreamofile;

ofile.open("temp.txt",ios:

:

out);

ifile.open("tongxunlu.txt",ios:

:

in);

if(!

ofile||!

ifile)

{

cout<

"<

return0;

}

stringname2;

cout<<"请输入您要修改的学生的姓名:

\t";

cin>>name2;

while(!

ifile.eof())

{

ifile>>name>>number>>phone>>qq;

if(name==name2)

{

cout<<"您要修改的人是:

\n";

cout<

n=1;

}

else

ofile<

}

if(n==0)

{

cout<<"您要修改的学生本来就不存在!

请检查重新输入!

"<

return0;

}

stringnam,num,q,pho;

cout<<"姓名:

";cin>>nam;

cout<<"学号:

";cin>>num;

cout<<"电话号码:

";cin>>pho;

cout<<"qq号码:

";cin>>q;

cout<

ofile<

ifile.close();

ofile.close();

ofstreamout("tongxunlu.txt",ios:

:

out|ios:

:

trunc);

ifstreamin("temp.txt",ios:

:

in);

while(!

in.eof())

{

in>>name>>number>>phone>>qq;

out<

}

out.close();

in.close();

system("pause");

return0;

}

//对联系人排序

inttongxunlu:

:

paixu()

{

system("cls");

intk,x;

tongxunlup[100];

fstreamfile;

intn=0;

tongxunlutemp;

ifstreamifile;

ofstreamofile;

ofile.open("temp.txt",ios:

:

out);

ifile.open("tongxunlu.txt",ios:

:

in);

if(!

ofile||!

ifile)

{

cout<

"<

return0;

}

while(!

ifile.eof())

{

ifile>>name>>number>>phone>>qq;

p[n].name=name;p[n].number=number;p[n].phone=phone;p[n].qq=qq;

n++;

}

n=n-1;

cout<<"\n\n\t1.按学号显示\n\t2.按姓名显示\n\t请选择排序方式:

";

cin>>x;

if(x==1)

{

for(k=1;k<=n;k++)

for(intj=0;j

if(p[j].number>p[j+1].number)

{

temp=p[j];

p[j]=p[j+1];

p[j+1]=temp;

}

cout<<"\n\t按学号方式排序"<

}

elseif(x==2)

{

for(k=1;k<=n;k++)

for(intj=0;j

if(p[j].name>p[j+1].name)

{

temp=p[j];

p[j]=p[j+1];

p[j+1]=temp;

}

cout<<"\n\t按姓名方式排序"<

}

else

{

cout<<"\

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1