资源描述
北 华 航 天 工 业 学 院
《基于C++面向对象程序设计实例》
课程设计报告
报 告 题 目 :高校人员信息管理系统
作者所在系部: 计算机科学与工程系
作者所在专业: 网络工程
作者所在班级: B08522班
作 者 姓 名 : 马洪彪
指引教师姓名: 赵辉
完 成 时 间 : 6月26日
北华航天工业学院教务处制
课程设计任务书
课题名称
高校人员信息管理系统
完毕时间
第18周
指引教师
职称
讲师
学生姓名
班 级
总体设计规定和技术要点
某高校,重要人员有:领导、教师和学生,共有信息涉及:编号、姓名、性别、年龄。其中领导还应包括信息有:任职部门(学院、各系部)、职称;教师还应包括信息有:职称、任职时间、专业;学生还应包括信息有:所在班级、所在宿舍等。
规定:对各类人员信息完毕基本功能有:
1) 添加功能:程序可以添加相应记录;
2) 查询功能:能依照编号和姓名进行查询,并显示相应记录信息;
3) 编辑功能:依照查询对相应记录进行修改;
4) 记录功能:能依照各种参数进行人员记录(如在职人数、党员人数、女工人数等);
5)删除功能:依照查找成果,完毕详细记录删除。
6)保存功能:将对高校人员信息进行添加、删除、修改成果保存到文本文献中。
学生在完毕本次课程设计基本规定后,进一步完善程序,从如下几种方面加以考虑:
1) 添加人员记录时,考虑各种数据有效性。
2)组合查询功能实现。
3)编辑数据时,注意操作以便
4)删除数据时,考虑删除操作以便
工作内容及时间进度安排
1.6月2日~13日:布置任务,软件设计
2.6月15日~26日:编写代码,上机调试
3.6月25、26日:软件验收,撰写课程设计报告
4.各班在6月29日下午四点前将课程设计报告收齐并上交
课程设计成果
1.课程设计报告
2.源程序代码
摘 要
在信息化教诲今天,高校要想实现教诲当代化,不但要又先进师资力量,同步也要有好软件系统。高校人员信息管理系统是一套完善信息化管理系统,用来实现高校人员统一以便信息操作,以实现高校人员流动及时更新、及时反馈校园信息、完善教诲质量、提高教诲效率、分析校园需求、制定招生和招聘管理目。
本文运用Microsoft visual c++6.0提供OOP(噢把巨额彩图噢日恩特等批rogrammin,OOP面向对象程序设计)编写程序,实现了校园内部人员信息添加,查询,编辑,记录,删除,载入,保存,加载等功能。
本系统重要有四个类:基类、领导类、教师类以及学生类。已通过全面系统测试,可以较好运营,基本达到了预期效果。
核心词:系统 类 信息管理
目 录
课程设计任务书 І
摘 要 ІІ
第一章 绪论 6
1.1 课程设计目 6
1.2 课程设计背景和意义 6
1.2.1 课程设计背景 6
1.2.2 课程设计意义 6
1.3 课程设计环境 7
第二章 需求分析 7
2.1 问题描述 7
2.2 功能规定 7
2.3 问题解决方案 8
第三章 系统设计 8
3.1 数据设计 8
3.1.1 类设计 8
3.1.2 类之间关系 14
3.1.3 函数设计 14
3.2 构造设计 15
3.2.1 系统流程图 15
3.2.2 界面设计 15
第四章 系统实现 16
4.1 类实现 16
图4-1 类构造图 16
4.2 函数实现 17
4.2.1 高校人员信息添加功能实现 17
4.2.2 高校人员信息查询功能实现 18
4.2.3 高校人员信息编辑功能实现 24
4.2.4 高校人员信息记录功能实现 26
4.2.5 高校人员信息删除功能实现 28
4.2.6 高校人员信息保存功能实现 30
4.2.7 高校人员信息加载功能实现 32
4.3 主函数实现 34
第五章 系统测试 36
5.1 模块测试 36
5.2 课程设计过程中遇到问题 40
总 结 41
致 谢 42
参照文献 43
附 录 44
第一章 绪论
1.1 课程设计目
课程设计是课程教学必不可缺一种重要环节,可加深学生对该课程所学内容进一步理解与巩固,是将计算机课程与实际问题相连接核心环节。通过课程设计,可以提高学生分析问题,解决问题,要能较好完毕课程设计,规定咱们必要掌握在学习中学到知识,因此要咱们对课本中学知识要熟悉且掌握,从而运用所学知识解决实际问题能力,因而必要予以足够注重。
1.2 课程设计背景和意义
1.2.1 课程设计背景
1. 理论研究基本
(1)C++语言基本知识和技能,如:类与对象,指针,输入/输出流,文本文献建立保存;
(2)面向对象程序设计基本思路和办法。
2. 技术层面支持
(1)研究这些构造存储、显示,并有查找、添加、删除、修改、查询、记录、保存信息、载入等功能。
(2)类定义、类对象、继承、抽象类、虚函数、虚基类、多态和文献输入/输出等内容。
1.2.2 课程设计意义
(1)通过课程设计综合训练,培养了学生分析解决实际问题和编程等实际动手能力。协助了同窗系统掌握C++课程重要内容。
(2)综合实际应用需求是课程设计既覆盖教学所规定知识点,有接近工程实际需求,训练自己实际分析问题和解决问题以及编程能力。做到理论结合实际。
1.3 课程设计环境
(1)在Microsoft Visual C++ 6.0开发平台上编写程序源代码,修改,增长功能,通过编译、连接,直到完全无误,最后执行程序,重复输入合理以及不合理数据进行测试并进一步完善。
(2)硬件:学校机房
(3)软件:Microsoft Visual C++ 6.0开发平台
第二章 需求分析
2.1 问题描述
某高校,重要人员有:领导、教师和学生,共有信息涉及:编号、姓名、性别、年龄。其中领导还应包括信息有:任职部门(学院、各系部)、职称;教师还应包括信息有:职称、任职时间、专业;学生还应包括信息有:所在班级、所在宿舍等。
2.2 功能规定
(1)对各类人员信息完毕基本功能有:
1) 添加功能:程序可以添加相应记录;
2) 查询功能:能依照编号和姓名进行查询,并显示相应记录信息;
3) 编辑功能:依照查询成果对相应记录进行修改;
4) 记录功能:能依照各种参数进行人员记录(如在职人数、党员人数、女工人数等);
5)删除功能:依照查找成果,完毕详细记录删除。
6)保存功能:将对高校人员信息进行添加、删除、修改成果保存到文本文献中。
7)载入功能:把文献中数据导入内存中,通过显示功能把载入数据显示在桌面上。
(2)学生在完毕本次课程设计基本规定后,进一步完善程序,从如下几种方面加以考虑:
1) 添加人员记录时,考虑各种数据有效性。
2)组合查询功能实现。
3)编辑数据时,注意操作以便。
4)删除数据时,考虑删除操作以便。
5)载入数据时,要考虑到操作简朴,快捷。
2.3 问题解决方案
依照系统功能规定,可以将问题解决分为如下环节:
1)应用系统分析,建立该系统功能模块框图以及界面组织和设计;
2)分析系统中各个实体及它们之间关系;
3)依照问题描述,设计系统类层次;
4)完毕类层次中各个类描述;
5)完毕类中各个成员函数定义;
6)完毕系统应用模块;
7)功能调试;
8)完毕系统总结报告。
第三章 系统设计
3.1 数据设计
3.1.1 类设计
***************************************************************************
基类:
***************************************************************************
class Person//定义基类Person
{
public:
Person(int n,string nam,char s,int a):num(n),name(nam),sex(s),age(a){}
int num;
string name;
protected:
char sex;
int age;
};
***************************************************************************
领导类:
***************************************************************************
class Leader:public Person//由基类派生出Leader(领导)类
{
public:
Leader(int n=0,string nam="",char s='m',int a=0,string d="",string p=""):Person(n,nam,s,a),dep(d),post(p){}
void set_leader()
{
cout<<"please input the number of leader(1 to 20):"; cin>>num;
for(int k=1;k<21;k++)
if(num==k)
k=21;
if(k==21)
{
cout<<"the number you putin is wrong,please input the information again"<<endl;
set_leader();
}//如果输入数字合法,则k=22;否则,k=21
cout<<"please input the name of leader:"; cin>>name;
cout<<"please input the sex of leader(m or f):"; cin>>sex;
if(sex!='m'&&sex!='f')
{
cout<<"the sex you putin is wrong,please input the information again"<<endl;
set_leader();
}
cout<<"please input the age of leader:"; cin>>age;
cout<<"please input the department of leader:"; cin>>dep;
cout<<"please input the post of leader:"; cin>>post;
}
void show_leader()
{
cout<<"number"<<"\t"<<"name"<<"\t"<<"sex"<<"\t"<<"age"<<"\t"<<"department"<<"\t"<<"post"<<endl;
cout<<num<<"\t"<<name<<"\t"<<sex<<"\t"<<age<<"\t"<<dep<<"\t\t"<<post<<endl;
}
void save_leader(ofstream &outf)
{
outf<<"number"<<"\t"<<"name"<<"\t"<<"sex"<<"\t"<<"age"<<"\t"<<"department"<<"\t"<<"post"<<endl;
outf<<num<<"\t"<<name<<"\t"<<sex<<"\t"<<age<<"\t"<<dep<<"\t\t"<<post<<endl;
}
void load_leader(ifstream &inf)
{
inf>>num>>name>>sex>>age>>dep>>post;
}
friend void LTongJi();
private:
string dep;
string post;
}led[20];
***************************************************************************
教师类:
***************************************************************************
class Teacher:public Person//由基类派生出Teacher(教师)类
{
public:
Teacher(int n=0,string nam="",char s='m',int a=0,string p="",string d="",string sp=""):Person(n,nam,s,a),post(p),day(d),spec(sp){}
void set_teacher()
{
cout<<"please input the number of teacher(1 to 20):"; cin>>num;
for(int k=1;k<21;k++)
if(num==k)
k=21;
if(k==21)
{
cout<<"the number you putin is wrong,please input the information again"<<endl;
set_teacher();
}//如果输入数字合法,则k=22;否则,k=21
cout<<"please input the name of teacher:"; cin>>name;
cout<<"please input the sex of teacher(m or f):"; cin>>sex;
if(sex!='m'&&sex!='f')
{
cout<<"the sex you putin is wrong,please input the information again"<<endl;
set_teacher();
}
cout<<"please input the age of teacher:"; cin>>age;
cout<<"please input the post of teacher:"; cin>>post;
cout<<"please input the day of teacher:"; cin>>day;
cout<<"please input the specialty of teacher:"; cin>>spec;
}
void show_teacher()
{
cout<<"number"<<"\t"<<"name"<<"\t"<<"sex"<<"\t"<<"age"<<"\t"<<"post"<<"\t"<<"time"<<"\t"<<"specialty"<<endl;
cout<<num<<"\t"<<name<<"\t"<<sex<<"\t"<<age<<"\t"<<post<<"\t"<<day<<"\t"<<spec<<endl;
}
void save_teacher(ofstream &outf)
{
outf<<"number"<<"\t"<<"name"<<"\t"<<"sex"<<"\t"<<"age"<<"\t"<<"post"<<"\t"<<"time"<<"\t"<<"specialty"<<endl;
outf<<num<<"\t"<<name<<"\t"<<sex<<"\t"<<age<<"\t"<<post<<"\t"<<day<<"\t"<<spec<<endl;
}
void load_teacher(ifstream &inf)
{
inf>>num>>name>>sex>>age>>post>>day>>spec;
}
friend void TTongJi();
private:
string post;
string day;
string spec;
}tea[20];
***************************************************************************
学生类:
***************************************************************************
class Student:public Person//定义由Person类派生出Student类
{
public:
Student(int n=0,string nam="",char s='m',int a=0,string c="",string d=""):Person(n,nam,s,a),cla(c),door(d){}
void set_student()
{
cout<<"please input the number of student(1 to 20):"; cin>>num;
for(int k=1;k<21;k++)
if(num==k)
k=21;
if(k==21)
{
cout<<"the number you putin is wrong,please input the information again"<<endl;
set_student();
}//如果输入数字合法,则k=22;否则,k=21
cout<<"please input the name of student:"; cin>>name;
cout<<"please input the sex of student(f or m):"; cin>>sex;
if(sex!='m'&&sex!='f')
{
cout<<"the sex you putin is wrong,please input the information again"<<endl;
set_student();
}
cout<<"please input the age of student:"; cin>>age;
cout<<"please input the class of student:"; cin>>cla;
cout<<"please input the dormitory of student:"; cin>>door;
}
void show_student()
{
cout<<"number"<<"\t"<<"name"<<"\t"<<"sex"<<"\t"<<"age"<<"\t"<<"class"<<"\t"<<"dormitory"<<endl;
cout<<num<<"\t"<<name<<"\t"<<sex<<"\t"<<age<<"\t"<<cla<<"\t"<<door<<endl;
}
void save_student(ofstream &outf)
{
outf<<"number"<<"\t"<<"name"<<"\t"<<"sex"<<"\t"<<"age"<<"\t"<<"class"<<"\t"<<"dormitory"<<endl;
outf<<num<<"\t"<<name<<"\t"<<sex<<"\t"<<age<<"\t"<<cla<<"\t"<<door<<endl;
}
void load_student(ifstream &inf)
{
inf>>num>>name>>sex>>age>>cla>>door;
}
friend void STongJi();
private:
string cla;
string door;
}stu[20];
3.1.2 类之间关系
基类为Person类。Leader类、Teacher类、Student类公用继承Person类
3.1.3 函数设计
void TianJia()******************************************添加功能函数
可以对人员信息进行添加,可以防止重复编号添加
void ChaXun()*****************************************查询功能函数
可按照编号或姓名进行人员信息查询
void BianJi()*******************************************编辑功能函数
可对人员信息进行修改
void TongJi()******************************************记录功能函数
可记录人员有关信息
void ShanChu()****************************************删除功能函数
查询到需要删除人员后,执行删除命令,可将其删除
void BaoCun()*****************************************保存功能函数
将人员信息保存在文本文档中
void JiaZai()*******************************************加载功能函数
将人员信息由文本文档加载到内存中
int main()***************************************************主函数
调用各个功能函数以及菜单函数
3.2 构造设计
3.2.1 系统流程图
图3-1 系统流程图
3.2.2 界面设计
(1)进入程序界面
图3-2 进入程序欢迎界面
(2)选取操作方式界面
图3-3 选取操作方式时界面
(3)选取操作对象界面
图3-4 选取操作对象时界面
(4)退出程序界面
图3-5 退出程序时界面
第四章 系统实现
4.1 类实现
定义基类Person类,然后由基类派生出Leader(领导)类、Teacher(教师)类、Student(学生)类。在各类中定义有关成员函数和数据成员
图4-1 类构造图
4.2 函数实现
4.2.1 高校人员信息添加功能实现
该功能用于对高校人员信息进行添加
(1)该函数分别调用(2)(3)(4)中函数,分别实现对领导、教师、学生信息添加
void TianJia()***************************************************添加功能函数
{
int i=1;
while(i)
{
int choice;
Menu();
cin>>choice;
switch(choice)
{
case 1:
LTianJia();break;//添加领导信息
case 2:
TTianJia();break;//添加教师信息
case 3:
STianJia();break;//添加学生信息
case 4:
i=0;break;
default:
cout<<"error,please input it again!"<<endl;
}
}
}
(2)对领导信息添加
void LTianJia()**********************************对领导类对象添加功能函数
{
led[Lcount].set_leader();//调用领导类成员函数添加信息
cout<<"succeed in adding"<<endl;
led[Lcount].show_leader();//调用领导类成员函数显示添加信息
Lcount++;
}
(3)对教师信息添加
void TTianJia()************************************对教师类对象添加功能函数
{
tea[Lcount].set_teacher();//调用教师类成员函数添加信息
cout<<"succeed in adding"<<endl;
tea[Lcount].show_teacher();//调用教师类成员函数显示添加信息
Tcount++;
}
(4)对学生信息添加
void STianJia()************************************对学生类对象添加功能函数
{
stu[Lcount].set_student();//调用学生类成员函数添加信息
cout<<"succeed in adding"<<endl;
stu[Lcount].show_student();//调用学生类成员函数显示添加信息
Scount++;
}
4.2.2 高校人员信息查询功能实现
该功能用于对高校人员信息进行查询,可按照编号或姓名进行查询
(1)该函数分别调用(2)(3)(4)中函数,分别实现对领导、教师、学生信息查询
void ChaXun()***********************************************查询功能函数
{
int i=1;
while(i)
{
int choice;
Menu();
cin>>choice;
switch(choice)
{
case 1:
LChaXun();break;//查询领导信息
case 2:
TChaXun();break;//查询教师信息
case 3:
SChaXun();break;//查询学生信息
case 4:
i=0;break;
default:
cout<<"error,please input it again!"<<endl;
}
}
}
(2)对领导信息查询
void LChaXun_num()**********************************按编号查询领导类对象
{
int n;
cout<<"please input the number of leader(1 to 20):";
cin>>n;
for(int i=0;i<Lcount;i++)
if(led[i].num==n)
{
led[i].show_leader();
i=Lcount;
}
if(i==Lcount)
{
cout<<"the leader you want to search isn`t sxist,please intput the number again"<<endl;
LChaXun_num();
}
}
void LChaXun_nam()**********************************按姓名查询领导类对象
{
string na_s;
cout<<"please input the name of leader"<<endl;
cin>>na_s;
for(int j=0;j<Lcount;j++)
if(led[j].name==na_s)
{
led[j].show_leader();
j=Lcount;
}
if(j==Lcount)
{
cout<<"the leader you want to search isn`t sxist,please intput the number again"<<endl;
LChaXun_nam();
}
}
void LChaXun()********************************对领导类对象查询功能函数
{
int w;
cout<<"please choice the way to search"<<endl;
cout<<"based on number:1"<<"\t"<<"based on name:2"<<endl;
cin>>w;
switch(w)
{
case 1:
LChaXun_num();break;
case 2:
LChaXun_nam();break;
default:
cout<<"error,please input it again"<<endl;
}
}
(3)对教师信息查询
void TChaXun_num()**********************************按编号查询教师类对象
{
int n;
cout<<"please input the number of teacher(1 to 20):";
cin>>n;
for(int i=0;i<Tcount;i++)
if(tea[i].num==n)
{
tea[i].show_teacher();
i=Tcount;
}
if(i==Tcount)
{
cout<<"the teacher you want to search isn`t sxist,please intput the number again"<<endl;
TChaXun_num();
}
}
void TChaXun_nam()**********************************按姓名查询教师类对象
{
string na_s;
cout<<"please input the name of teacher"<<endl;
cin>>na_s;
for(int j=0;j<Tcount;j++)
if(tea[j].name==na_s)
{
tea[j].show_teacher();
j=Tcount;
}
if(j==Tcount)
{
cout<<"the teacher you want to search isn`t sxist,please intput the number again"<<endl;
TChaXun_nam();
}
}
void TChaXun()********************************对教师类对象查询功能函数
{
int w;
cout<<"please choice the way to search"<<endl;
cout<<"based on number:1"<<"\t"<<"based on name:2"<<endl;
cin>>w;
switch(w)
{
case 1:
TChaXun_num();break;
case 2:
TChaXun_nam();break;
default:
cout<<"error,please input it again"<<endl;
}
}
(4)对学生信息查询
void SChaXun_num()**********************************按编号查询学生类对象
{
int n;
cout<<"please input the number of student(1 to 20):";
cin>>n;
for(int i=0;i<Scount;i++)
if(stu[i].num==n)
{
stu[i].show_student();
i=Scount;
}
if(i==Scount)
{
cout<<"the student you want to search isn`t sxist,please intput the number of leader again"<<endl;
SChaXun_num();
}
}
void SChaXun_nam()**********************************按姓名查询学生类对象
{
string na_s;
cout<<"please input the name of student"<<endl;
cin>>na_s;
for(int j=0;j<Scount;j++)
if(stu[j].name==na_s)
{
stu[j].show_student();
j=Scount;
}
if(j==Scount)
{
cout<<"the student you want to search isn`t sxist,please intput the number again"<<endl;
SChaXun_nam();
}
}
void SChaXun()********************************对学生类对象查询功能函数
{
int w;
cout<<"please choice the way to search"<<endl;
cout<<"based on number:1"<<"\t"<<"based on name:2"<<endl;
cin>>w;
switch(w)
{
case 1:
SChaXun_num();break;
case 2:
SChaXun_nam();break;
default:
cout<<"error,please input it again"<<endl;
}
}
4.2.3 高校人员信息编辑功能实现
该功能用于对高校人员信息进行编辑,在查询到需要编辑人员后进行编辑
(1)该函数分别调用(2)(3)(4)中函数,分别实现对领导、教师、学生信息编辑
void BianJi()*************************************************编辑功能函数
{
int i=1;
while(i)
{
int choice;
Menu();
展开阅读全文