南航通讯录管理系统面向对象程序设计C++课设报告.docx
《南航通讯录管理系统面向对象程序设计C++课设报告.docx》由会员分享,可在线阅读,更多相关《南航通讯录管理系统面向对象程序设计C++课设报告.docx(36页珍藏版)》请在冰豆网上搜索。
![南航通讯录管理系统面向对象程序设计C++课设报告.docx](https://file1.bdocx.com/fileroot1/2023-1/29/2f23baee-f260-4b18-a021-3878cc4df8dd/2f23baee-f260-4b18-a021-3878cc4df8dd1.gif)
南航通讯录管理系统面向对象程序设计C++课设报告
面向对象程序设计语言
--课程设计
题目通信录管理系统
院系自动化学院
专业
学生姓名
学号
指导教师张德平
二0一二年6月15日
课题内容与要求
通信录管理系统
用C/C++设计出模拟手机通信录管理系统,实现对手机中的通信录进行管理。
(一)功能要求
(1)查看功能:
选择此功能时,列出下列三类选择。
A办公类B个人类C商务类,当选中某类时,显示出此类所有数据中的姓名和电话号码)
(2)增加功能:
能录入新数据(一个结点包括:
姓名、电话号码、分类(可选项有:
A办公类B个人类C商务类)、电子邮件)。
例如
杨春13589664454商务类chuny@
当录入了重复的姓名和电话号码时,则提示数据录入重复并取消录入;当通信录中超过15条信息时,存储空间已满,不能再录入新数据;录入的新数据能按递增的顺序自动进行条目编号。
(3)拔号功能:
能显示出通信录中所有人的姓名,当选中某个姓名时,屏幕上模拟打字机的效果依次显示出此人的电话号码中的各个数字,并伴随相应的拔号声音。
(4)修改功能:
选中某个人的姓名时,可对此人的相应数据进行修改
(5)删除功能:
选中某个人的姓名时,可对此人的相应数据进行删除,并自动调整后续条目的编号。
(二)其它要求:
(1)只能使用C/C++语言,源程序要有适当的注释,使程序容易阅读
(2)至少采用文本菜单界面(如果能采用图形菜单界面更好)
(3)建议使用结构和链表等数据结构
(4)学生可自动增加新功能模块(视情况可另外加分)
(5)写出课程设计报告,具体要求见相关说明文档
一、需求分析……………………………………………………4
二、软件总体设计………………………………………………5
三、软件详细设计………………………………………………5
四、编码…………………………………………………………9
五、测试说明……………………………………………………24
六、总结…………………………………………………………30
一、需求分析
通讯录管理系统主要用来实现以下功能:
1.进行用户的注册、登录等操作;
2.对信息进行添加、删除、修改等操作;
3.对信息进行分类、查询、拨号等操作。
本系统将通讯录的管理变得简单、有条理、具有隐私性、具有安全性,使通讯录使用起来方便快捷。
(1)系统简介
本系统主要用来保存以下信息:
1.用户登录名、登录密码、注册密码;
2.通讯录:
姓名、电话、类型、邮箱;
包含功能有添加、修改、删除、拨号、显示、登录、注册、退出、分类管理等。
(2)分析
本系统提前已设置好管理员密码,需要输入并注册登录后,即可使用。
系统界面简洁,操作性强,因为需要用户名以及密码,所以安全可靠,使用起来放心安心。
(3)功能描述
1.菜单界面
程序运行后,将出现3个选项:
1.登录
2.注册
3.退出
选择0、1、2数字即可进行操作,进入下一个菜单。
成功登录后,界面有7个选项:
1.添加新联系人2.删除联系人
3.修改信息4.拨号
5.查看联系人6.显示所有人
7.关闭通讯录
2.登录
只有在输入正确的用户名与密码,才可登录,进入通讯录管理系统,进行下一步操作。
3.注册
此选项需要注册权限密码才可进行注册(本系统的密码为:
123456)。
输入用户名,密码(两次密码必须相同才可),即可成功注册。
4.退出
退出运行。
5.添加、修改、删除联系人
此功能的信息保存在“pbook.txt”中,可以通过系统的输入、修改、删除来进行联系人管理,当然,也可以直接使用此文件来进行管理。
6.拨号
在系统中输入想要拨打的联系人名字或电话,即可发声拨号。
7.显示联系人
选中此功能,不论联系人类型均可显示出来。
二、软件总体设计
通讯录管理系统:
首先,包含三个选项:
0.退出;1.登录;2.注册。
在成功登录后,有七大功能:
1.添加新联系人;2.删除联系人;3.修改信息;4.拨号;5.查看联系人;6.显示所有人;7.关闭通讯录。
成功登录后,或者成功注册后登录后,可以进行上述七大功能。
所有信息的输入输出均有系统的提示,可以安心完成。
通信录系统总设计图
程序由哪些模块组成以及模块之间的层次结构、各模块的调用关系;每个模块的功能。
三、软件详细设计
具体的模块流程图:
2)模块流程图
a.
添加联系人流程图
b.修改联系人
N
y
c.注册登录用户名
N
Y
n
y
d.搜索模块(即显示所有人,显示同类人,拨号功能)
n
y
e.以上模块的数据以及函数在类中的声明如下:
classbook
{
public:
book();//默认构造函数
intenter1();//通讯录管理首页
voidaddPer();//添加联系人
voiddelPer();//删除联系人
voidalter();//修改信息
voidcall();//拨号
voidshowall();//显示所有信息
voidsave();//保存通讯录文件
voidshow();//显示查询的类型
voidshowA();//显示类型A
voidshowB();//显示类型B
voidshowC();//显示类型C
private:
stringname;//姓名
stringnumber;//电话
stringtype;//类型
stringemail;//电子信箱
};
structrecord
{
bookobject;//双向链表中的数据域是是一个记录类
record*prior;//指向前躯
record*next;//指向后继
};
f.密码模块
数据声明:
stringuser;//用户名
stringcode;//密码
stringcode1;//注册校对密码
函数声明:
intenter();//密码登录首页
intcheck();//校对登录密码
voidlogin();//创建注册密码
四、编码
//PASSWORD:
密码登陆
//Password.h文件的内容:
#include"stdafx.h"
#ifndefPASSWORD_H
#definePASSWORD_H
intenter();//登录页面
intcheck();//核对密码
voidlogin();//注册
#endif
//文件Password.cpp的内容:
#include
#include
#include"password.h"
#include
#include
#include
#include
#include
#include
usingnamespacestd;
stringuser;//用户名
stringcode;//密码
stringcode1;//注册密码
intcheck()
{
ifstreaminfile("code.txt",ios:
:
in);
if(!
infile)
{
cout<文件打开失败!
"<exit
(1);
}
stringsign;//定义用户名字符串
stringsign1;//定义密码字符串
cout<";
cin>>sign;
fflush(stdin);
cout<";
cin>>sign1;
fflush(stdin);//清除缓存
intflag=1;
stringstr;
while(infile>>user>>code)//读出数据
{
getline(infile,str);
if((user==sign)&&(code==sign1))//检查用户名,密码是否正确
{
cout<flag=0;
}
}
cout<请重新输入!
"<system("pause");//显示“按任意键继续……
returnflag;
}
voidlogin()//用户注册
{
system("cls");//清屏
cout<<"请输入管理员注册权限密码:
";
stringstr;
str="123456";
stringstr1;
cin>>str1;
if(str1==str)
{
cout<<"通过认证!
!
!
"<cout<<"请创建新的用户名:
";
cin>>user;
fflush(stdin);
cout<<"请输入密码:
";
cin>>code;
fflush(stdin);
cout<<"请重新输入密码:
";
cin>>code1;
while(code!
=code1)//比较两次输入的密码
{
cout<<"创建失败!
"<cout<<"请重新输入密码:
";
cin>>code1;
}
cout<<"创建成功!
"<ofstreamoutfile("code.txt",ios:
:
app);//以追加模式打开文件
if(!
outfile)
{
cout<文件打开失败!
"<system("pause");
}
outfile<:
left)<outfile.close();//关闭文件
cout<<"用户已成功保存!
"<system("pause");
}
else
{
cout<您没有通过注册认证!
"<cout<QQ:
123456789;tel:
12345678989"<system("pause");
}
}
intenter()//登录页面
{
system("cls");//清屏
system("color9D");//背景与字体颜色
cout<<<"\t\t************************************************"<<<"\t\t通讯录登录系统"<<<"\t\t1.登录"<<<"\t\t2.注册"<<<"\t\t0.退出"<<<"\t\t************************************************"<<<"\t\t选择:
";
intchoose;
cin>>choose;
fflush(stdin);
returnchoose;
}
//通信录管理系统_xxxxxxxx.cpp文件的内容
#include
#include
#include"password.h"
#include
#include
#include
#include
#include
#include
usingnamespacestd;
classbook
{
public:
book();//构造函数
intenter1();//管理首页
voidaddPer();//添加联系人
voiddelPer();//删除联系人
voidalter();//修改信息
voidcall();//拨号
voidshowall();//显示所有联系人的信息
voidsave();//保存
voidshow();//显示查询的类型
voidshowA();//显示类型A
voidshowB();//显示类型B
voidshowC();//显示类型C
private:
stringname;//姓名
stringnumber;//电话
stringtype;//类型
stringemail;
};
structrecord
{
bookobject;
record*prior;
record*next;
};
book:
:
book()//构造函数
{
name='\0';
type='\0';
number='\0';
email='\0';
}
intbook:
:
enter1()//管理页面
{
system("cls");
system("color7D");//背景与字体颜色
cout<cout<cout<<"\t\t\t*****************************************"<<<"\t\t\t通讯录管理系统"<<<"\t\t\t"<<<"\t\t\t1.添加新联系人2.删除联系人"<<<"\t\t\t"<<<"\t\t\t3.修改信息4.拨号"<<<"\t\t\t"<<<"\t\t\t5.查看联系人6.显示所有联系人"<<<"\t\t\t"<<<"\t\t\t7.关闭通讯录系统"<<<"\t\t\t"<<<"\t\t\t***********************************"<<<"\t\t\t选择:
";
intchoose1;
cin>>choose1;
fflush(stdin);
returnchoose1;
}
voidbook:
:
addPer()//添加联系人
{
cout<cout<<"姓名:
";
cin>>name;
fflush(stdin);
cout<<"电话:
";
cin>>number;
fflush(stdin);
cout<cout<<"类型(A:
办公类B:
个人类C:
商务类):
";
cin>>type;
fflush(stdin);
cout<<"邮箱:
";
cin>>email;
fflush(stdin);
save();//保存
cout<"<system("pause");
}
voidbook:
:
delPer()//删除联系人
{
ofstreamoutfile("temp.txt",ios:
:
out);
ifstreaminfile("pbook.txt",ios:
:
in);
if(!
outfile||!
infile)
{
cout<<"对不起!
文件打开失败!
"<exit(0);
}
stringsign;
cout<";
cin>>sign;
boolflag=true;
stringstr;
while(infile>>name>>number)
{
getline(infile,str);
if((sign==name)||(sign==number))
{
cout<"<cout<:
left)<flag=false;
break;
}
outfile<:
left)<}
if(flag)
{
cout<<"对不起!
未找到联系人!
"<}
else
{
while(getline(infile,str))
{
outfile<}
outfile.close();
infile.close();
ofstreamout("pbook.txt",ios:
:
out);
ifstreamin("temp.txt",ios:
:
in);
if(!
out||!
in)
{
cout<<"对不起!
文件打开失败!
"<exit(0);
}
while(getline(in,str))
{
out<}
out.close();
in.close();
cout<"<}
system("pause");
}
voidbook:
:
alter()//修改信息
{
ifstreaminfile("pbook.txt",ios:
:
in);
if(!
infile)
{
cout<文件打开失败!
"<exit(0);
}
stringsign;
cout<";
cin>>sign;
fflush(stdin);
record*H=newrecord;//记录链表
record*p=H;
boolflag=true;
while(infile>>p->object.name>>p->object.number>>p->object.type>>p->object.email)
{
p->next=newrecord;
p=p->next;
}
p->next=NULL;
infile.close();
p=H;
while(p!
=NULL)
{
if((p->object.name==sign)||(p->object.number==sign))
{
if(flag)
{
cout<"<cout<:
left)<<object.name<<""<object.number
<<""<object.type
<<""<object.email<flag=false;
}
cout<"<cout<<"姓名:
";
cin>>p->object.name;
fflush(stdin);
cout<<"电话:
";
cin>>p->object.number;
fflush(stdin);
cout<<"类型:
";
cin>>p->object.type;
fflush(stdin);
cout<<"邮箱:
";
cin>>p->object.email;
fflush(stdin);
break;
}
p=p->next;
}
if(flag)
{
cout<通迅录中没有你要找的联系人!
"<system("pause");
}
else
{
ofstreamout("pbook.txt",ios:
:
out);
if(!
out)
{
cout<文件打开失败!
"<system("pause");
}
p=H;
while(p!
=NULL)
{
out<:
left)<object.name
<<""<object.number
<<""<object.type
<<""<object.email<p=p->next;
}
out.close();
cout<"<system("pause");
}
}
voidbook:
:
call()//拨号功能
{
ifstreaminfile("pbook.txt",ios:
:
in);
if(!
infile)
{
cout<文件打开失败!
"<system("pause");
}
stringsign;
cout<";