




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、*实践教学* 兰州理工大学计算机与通信学院2011年秋季学期 面向对象 课程设计题 目: 高校人事管理系统 专业班级:计算机科学与技术四班姓 名: 李晓芬 学 号: 10240441 指导教师: 朱红蕾 成 绩: 摘 要在当前的全球信息化的浪潮中,无论是企业、政府机关,还是各大高校,要想完善自身的管理体系,就必须拥有一套完善的并且适合自身特点的信息化管理系统,以实现降低管理成本、及时反馈人员变动信息、节省人力资源、提高经济效益、完善管理体系等目的。 以高校为例,本文利用Microsoft Visual C+ 6.0编写程序,实现了用户对学校教师、实验员、行政人员、教师兼实验员和行政人员兼职教师
2、5类人员的工资管理,简单明了,容易操作。本程序主要有六个功能模块:添加人员信息、查询人员信息、修改人员信息、删除人员信息、显示人员信息和保存人员信息。已经过全面的系统测试,能够很好的运行,达到了预期的效果。关键词:程序设计 C+ 人员信息 工资管理目 录摘 要1第一章 绪论311 课程设计的目的312 课程设计的背景和意义3121 课程设计的背景3122 课程设计的意义313 课程设计环境3第二章 需求分析421 问题描述422 功能要求423 问题的解决方案4第三章 系统设计631 数据设计6311 类设计6312 类之间的关系7313 函数设计732 结构设计7第四章 系统测试1241 模
3、块测试1242 课程设计过程中遇到的问题15参考文献16附 录17总 结42致 谢43 第1章 绪论11 课程设计的目的1、熟练掌握C+语言的基本知识和技能。2、基本掌握面向对象程序设计的基本思路和方法。3、利用所学的基本知识和技能,解决简单的面向对象程序设计问题。12 课程设计的背景和意义121 课程设计的背景1. 理论研究基础(1)c+语言的基本知识和技能,如:类与对象,输入和输出,文本文件的建立和保存等。(2)面向对象的程序设计的基本思路和方法。 2. 技术层面的支持Microsoft Visual C+ 6.0编译平台122 课程设计的意义以高校为例,本文利用Microsoft Vis
4、ual C+ 6.0编写程序,实现了用户对学校教师、实验员、行政人员、教师兼实验员和行政人员兼职教师5类人员的工资管理,实现了降低管理成本、及时反馈人员变动信息、节省人力资源、提高经济效益、完善管理体系等目的。同时,锻炼自己,利用所学的基本知识和技能,解决简单的面向对象程序设计问题。1. 3 课程设计环境软件:Windows XP professional SP2操作系统 Microsoft Visual C+ 6.0第2章 需求分析21 问题描述某高校有五类职工:教师,实验员,行政人员,教师兼职实验员,行政人员兼职教师。共有的信息包括:编号、姓名、性别和职工类别。每类人员特有的信息,请根据情
5、况自行添加。职工工资的计算方法如下:教师: 基本工资+课时费;实验员: 基本工资+实验室补助;行政人员: 基本工资+行政补贴;教师兼职实验员: 基本工资+课时费+实验室补助;行政人员兼职教师:基本工资+行政补贴+课时费;其中:1)基本工资:教师800元,实验员650元,行政人员750元2)行政补贴:250元3)实验室补助:150元4)课时费的计算方法为:20*本月课时数22 功能要求(1)对各类人员信息完成的基本功能有:1) 添加功能:程序能够添加相应的记录;2) 查询功能:能根据编号和姓名进行查询,并显示相应的记录信息;3) 编辑功能:根据查询结果对相应的记录进行修改;4)删除功能:根据查找
6、结果,完成具体记录的删除。5)保存功能:将对高校人员信息进行的添加、删除、修改结果保存到文本文件中。(2)本程序处理的任务是:输入职工的相关数据,经过计算后,输出职工的月工资,并将所有信息保存在文本文件中。(3)学生在完成本次课程设计的基本要求后,进一步完善程序,从如下几个方面加以考虑:1) 添加人员记录时,考虑各种数据的有效性。2)组合查询功能的实现。3)编辑数据时,注意操作的方便4)删除数据时,考虑删除操作的方便5)输入、输出操作时的方便、易用23 问题的解决方案根据系统功能要求,可以将问题解决分为以下步骤: 1)应用系统分析,建立该系统的功能模块框图以及界面的组织和设计;2)分析系统中的
7、各个实体及它们之间的关系; 3)根据问题描述,设计系统的类层次; 4)完成类层次中各个类的描述; 5)完成类中各个成员函数的定义; 6)完成系统的应用模块; 7)功能调试; 8)完成系统总结报告。 第三章 系统设计31 数据设计311 类设计1基类person:包含各类人员所共有的属性(编号num、姓名name、性别sex、职工类别title和exist(判断对象是否删除)作为数据成员,供各个派生类继承。2教师类teacher:公用虚继承person类,并包括本月课时数classnum、教师基本工资工资salary1和教师工资teacher_salary作为本类数据成员。3实验员类test:公
8、用虚继承person类,并包括实验员基本工资工资salary2、实验室补助test_allowance和实验员工资test_salary作为本类数据成员。4行政人员类official:公用虚继承person类,并包括行政人员基本工资工资salary3、行政补贴official_allowance和行政人员工资test_salary作为本类数据成员。5教师兼实验员类teacher_test:多重继承teacher类和test类,并包括教师兼实验员工资salary4作为本类数据成员。6行政人员兼教师类teacher_official:多重继承teacher类和official类,并包括行政人员兼教
9、师工资salary5作为本类数据成员。7操作operate类:为以上各类的友元类,用于求各类对象的工资。3 12 类之间的关系PersonTestTeacherOfficialTeacher_test Teacher_officialOperate友元类公 有 虚 继 承多 重 继 承多 重 继 承如图,定义基类person,定义三个派生类teacher、test、official公有虚继承person类(虚继承是为了避免二义性),再定义teacher_test和teacher_official两个类分别多重继承teacher、test和teacher、official。定义operate类为
10、各类友元类。313 函数设计1.person类成员函数person()exist=1; 无参构造函数person(string n,string na,char s,string ti):num(n),name(na),sex(s),title(ti)exist=1; 构造函数void person_set() set函数,用于添加对象和修改对象数据void person_input(ifstream& iput) person_input函数,用于从文件读取数据void person_display() person_display函数,用于向显示器输出数据void person_o
11、utput(ofstream& oput) person_output函数,用于向文件输出数据string person_getnum() string person_getnum函数,用于获取num值string person_getname() string person_getname函数,用于获取name值void changeexist() void changeexist函数,用于改变exist值int person_exist() int person_exist函数,用于获得exist值2.教师类成员函数teacher() 无参构造函数teacher(string n,
12、string na,char s,string ti,int sa,int cnum):person(n,na,s,ti),salary1(sa),classnum(cnum) 构造函数void teacher_set() set函数,用于添加对象和修改对象数据void teacher_input(ifstream& iput) teacher_input函数,用于从文件读取数据void teacher_display() teacher_display函数,用于向显示器输出数据void teacher_output(ofstream& oput) teacher_output
13、函数,用于向文件输出数据string teacher_getnum() teacher_getnum函数,用于获取num值string teacher_getname() teacher_getname函数,用于获取name值3.实验员类成员函数test() 无参构造函数test(string n,string na,char s,string ti,int sa):person(n,na,s,ti),salary2(sa) 构造函数void test_set() set函数,用于添加对象和修改对象数据void test_input(ifstream& iput) test_input
14、函数,用于从文件读取数据void test_display() test_display函数,用于向显示器输出数据void test_output(ofstream& oput) test_output函数,用于向文件输出数据string test_getnum() test_getnum函数,用于获取num值string test_getname() test_getname函数,用于获取name值4.行政人员类成员函数official() 无参构造函数official(string n,string na,char s,string ti,int sa):person(n,na,s
15、,ti),salary2(sa) 构造函数void official_set() set函数,用于添加对象和修改对象数据void official_input(ifstream& iput) official_input函数,用于从文件读取数据void official_display() official_display函数,用于向显示器输出数据void official_output(ofstream& oput) official_output函数,用于向文件输出数据string official_getnum() official_getnum函数,用于获取num值st
16、ring official_getname() official_getname函数,用于获取name值5.教师兼实验员类成员函数teacher_test() 无参构造函数teacher_test(string n,string na,char s,string ti,int sa):person(n,na,s,ti),salary2(sa) 构造函数void teachertest_set() set函数,用于添加对象和修改对象数据void teachertest_input(ifstream& iput) teachertest_input函数,用于从文件读取数据void teac
17、hertest_display() teachertest_display函数,用于向显示器输出数据void teachertest_output(ofstream& oput) teachertest_output函数,用于向文件输出数据string teachertest_getnum() teachertest_getnum函数,用于获取num值string teachertest_getname() teachertest_getname函数,用于获取name值6.行政人员兼教师类成员函数teacher_official() 无参构造函数teacher_official(str
18、ing n,string na,char s,string ti,int sa):person(n,na,s,ti),salary2(sa) 构造函数void teacherofficial_set() set函数,用于添加对象和修改对象数据void teacherofficial_input(ifstream& iput) teacherofficial_input函数,用于从文件读取数据void teacherofficial_display() teacherofficial_display函数,用于向显示器输出数据void teacherofficial_output(ofst
19、ream& oput) teacherofficial_output函数,用于向文件输出数据string teacherofficial_getnum() teacherofficial_getnum函数,用于获取num值string teacherofficial_getname() teacherofficial_getname函数,用于获取name值7.operate类成员函数void operate1(teacher &p) operate1函数,用于求教师类对象的工资void operate2(test &p) operate2函数,用于求实验员类对象的工资v
20、oid operate3(official &p) operate3函数,用于求行政人员类对象的工资void operate4(teacher_test &p) operate4函数,用于求教师兼实验员类对象的工资void operate5(teacher_official &p) operate5函数,用于求行政人员兼教师类对象的工资3.2结构设计主函数从文档读入从键盘输入查询添加修改删除保存查询添加修改删除保存第4章 系统测试41 模块测试测试抓图:42 课程设计过程中遇到的问题刚开始做课设时,的确遇到了很多问题,比如对象怎么删除、怎么存档等。在老师的帮助下,自己也
21、参考了一些书,逐渐打开了思路,解决了问题。例如,定义对象时加一个变量exist,通过改变它的值来判断是否删除;把各个类的对象分开存在不同的文档,并引入计数变量来统计各个类的对象数,方便下次读入数据。解决了这些问题,感到自己的编程水平有明显提高,对于一些常见问题能够很好的解决了。参考文献1陈维兴,林小茶.c+面向对象程序设计教程. 北京: 清华大学出版社,1996.2004.2张国峰. C+程序设计实用教程. 北京: 清华大学出版社,1996. 3张松梅. C+语言教程. 电子科技大学出版社,1993. 4阎龙. C程序员的C+指南. 北京航空航天大学出版社,1992.5王博. 面向对象的建模、
22、设计技术与方法. 北京希望电脑公司,1990.附 录 程序代码: Salary.h:#include<iostream>#include<fstream>#include<string>using namespace std;class operate;/基类“人”class personpublic: person()exist=1; person(string n,string na,char s,string ti):num(n),name(na),sex(s),title(ti)exist=1; void person_set();void pers
23、on_input(ifstream& iput);void person_display();void person_output(ofstream& oput);string person_getnum();string person_getname();void changeexist();int person_exist(); friend operate;private:string num;string name;char sex;string title;int exist;/教师类class teacher:virtual public personpublic:
24、teacher()teacher(string n,string na,char s,string ti,int sa,int cnum):person(n,na,s,ti),salary1(sa),classnum(cnum)void teacher_set();void teacher_input(ifstream& iput);void teacher_display();void teacher_output(ofstream& oput);string teacher_getnum();string teacher_getname(); friend operate;
25、protected:int classnum;private:int salary1;static int teacher_salary;/实验员类class test:virtual public personpublic: test() test(string n,string na,char s,string ti,int sa):person(n,na,s,ti),salary2(sa) void test_set();void test_input(ifstream& iput);void test_display();void test_output(ofstream&am
26、p; oput);string test_getnum();string test_getname(); friend operate;private:int salary2;static int test_salary;static int test_allowance;/行政人员类class official:virtual public personpublic: official() official(string n,string na,char s,string ti,int sa):person(n,na,s,ti),salary3(sa) void official_set()
27、;void official_input(ifstream& iput);void official_display();void official_output(ofstream& oput);string official_getnum();string official_getname(); friend operate;private:int salary3;static int official_salary;static int official_allowance;/教师兼职实验员class teacher_test:public teacher,public t
28、estpublic: teacher_test() teacher_test(string n,string na,char s,string ti,int sa1,int sa2,int cnum,int sa3):teacher(n,na,s,ti,sa1,cnum),test(n,na,s,ti,sa2),salary4(sa3) void teachertest_set();void teachertest_input(ifstream& iput);void teachertest_display();void teachertest_output(ofstream&
29、 oput);string teachertest_getnum();string teachertest_getname(); friend operate;private:int salary4;/行政人员兼教师类成员函数class teacher_official:public teacher,public officialpublic: teacher_official() teacher_official(string n,string na,char s,string ti,int sa1,int sa2,int cnum,int sa3):teacher(n,na,s,ti,sa
30、1,cnum),official(n,na,s,ti,sa2),salary5(sa3) void teacherofficial_set();void teacherofficial_input(ifstream& iput);void teacherofficial_display();void teacherofficial_output(ofstream& oput);string teacherofficial_getnum();string teacherofficial_getname(); friend operate;private:int salary5;/
31、operate类class operatepublic: void operate1(teacher &); void operate2(test &); void operate3(official &); void operate4(teacher_test &); void operate5(teacher_official &);Salary.cpp:#include<iostream>#include<fstream>#include<string>#include"salary.h"us
32、ing namespace std;/人类成员函数void person:person_set()cin>>num>>name>>sex>>title;void person:person_input(ifstream& iput)iput>>num;iput>>name;iput>>sex;iput>>title;void person:person_display()cout<<"编号:"<<num<<" "co
33、ut<<"姓名:"<<name<<" "cout<<"性别:"<<sex<<" "cout<<"职工类别:"<<title<<" "void person:person_output(ofstream& oput)oput<<num<<" "oput<<name<<" "op
34、ut<<sex<<" "oput<<title<<" "string person:person_getnum()return num;string person:person_getname()return name;void person:changeexist()exist=0;int person:person_exist()return exist;/教师类成员函数void teacher:teacher_set()person_set();cin>>classnum;void tea
35、cher:teacher_input(ifstream& iput)person_input(iput);iput>>classnum;iput>>salary1;void teacher:teacher_display()if(person_exist()!=0)person_display();cout<<"本月课时数:"<<classnum<<" "cout<<"工资:"<<salary1<<endl;void teacher
36、:teacher_output(ofstream& oput)if(person_exist()!=0)person_output(oput);oput<<classnum<<" "oput<<salary1<<endl;string teacher:teacher_getnum()string str;str=person_getnum();return str;string teacher:teacher_getname()string str;str=person_getname();return str;int
37、 teacher:teacher_salary=800;/实验员类成员函数void test:test_set()person_set();void test:test_input(ifstream& iput)person_input(iput);iput>>salary2;void test:test_display()if(person_exist()!=0)person_display();cout<<"工资:"<<salary2<<endl;void test:test_output(ofstream&
38、; oput)if(person_exist()!=0)person_output(oput);oput<<salary2<<endl;string test:test_getnum()string str;str=person_getnum();return str;string test:test_getname()string str;str=person_getname();return str;int test:test_salary=650;int test:test_allowance=150;/行政人员类成员函数void official:officia
39、l_set()person_set();void official:official_input(ifstream& iput)person_input(iput);iput>>salary3;void official:official_display()if(person_exist()!=0)person_display();cout<<"工资:"<<salary3<<endl;void official:official_output(ofstream& oput)if(person_exist()!=
40、0)person_output(oput);oput<<salary3<<endl;string official:official_getnum()string str;str=person_getnum();return str;string official:official_getname()string str;str=person_getname();return str;int official:official_salary=750;int official:official_allowance=250;/教师兼实验员类成员函数void teacher_
41、test:teachertest_set()teacher_set();void teacher_test:teachertest_input(ifstream& iput)person_input(iput);iput>>classnum;iput>>salary4;void teacher_test:teachertest_display()if(person_exist()!=0)person_display();cout<<"本月课时数:"<<classnum<<" "cout&
42、lt;<"工资:"<<salary4<<endl;void teacher_test:teachertest_output(ofstream& oput)if(person_exist()!=0)person_output(oput);oput<<classnum<<" "oput<<salary4<<endl;string teacher_test:teachertest_getnum()string str;str=teacher_getnum();return s
43、tr;string teacher_test:teachertest_getname()string str;str=teacher_getname();return str;/行政人员兼教师类成员函数void teacher_official:teacherofficial_set()teacher_set();void teacher_official:teacherofficial_input(ifstream& iput)person_input(iput);iput>>classnum;iput>>salary5;void teacher_offici
44、al:teacherofficial_display()if(person_exist()!=0)person_display();cout<<"本月课时数:"<<classnum<<" "cout<<"工资:"<<salary5<<endl;void teacher_official:teacherofficial_output(ofstream& oput)if(person_exist()!=0)person_output(oput);oput<
45、;<classnum<<" "oput<<salary5<<endl;string teacher_official:teacherofficial_getnum()string str;str=teacher_getnum();return str;string teacher_official:teacherofficial_getname()string str;str=teacher_getname();return str;/operate类成员函数void operate:operate1(teacher &p)
46、p.salary1=p.teacher_salary+20*p.classnum;void operate:operate2(test &p)p.salary2=p.test_salary+p.test_allowance;void operate:operate3(official &p)p.salary3=p.official_salary+p.official_allowance;void operate:operate4(teacher_test &p)p.salary4=p.teacher_salary+20*p.classnum+p.test_salary+
47、p.test_allowance;void operate:operate5(teacher_official &p)p.salary5=p.teacher_salary+20*p.classnum+p.official_salary+p.official_allowance;Main.cpp:#include<iostream>#include<fstream>#include<string>#include"salary.h"using namespace std;int main()/定义各类的对象数组及操作类的对象teac
48、her t100;test te100;official o100;teacher_test t_te100;teacher_official t_o100;operate op;ifstream infile,infile1,infile2,infile3,infile4,infile5;ofstream outfile,outfile1,outfile2,outfile3,outfile4,outfile5;/选择标记int a=0,b=0,c=0,d=0,x=0;/位置标记int p=0,i=0,j=0,k=0,l=0,m=0,n=0,del=0;/结束标记char CorN;/界面说明
49、cout<<""<<endl;cout<<" "<<endl;cout<<" "<<endl;cout<<" 欢 迎 使 用 "<<endl;cout<<" 高校人员工资管理系统 "<<endl;cout<<" "<<endl;cout<<" "<<endl;cout<<&quo
50、t;"<<endl;/数据输入cout<<"请选择数据输入方式:1.从键盘输入 2.从文档读入"<<endl;cin>>x;if(x<1|x>2)cout<<"输入错误!"<<endl;if(x=1)cout<<""<<endl;cout<<"请输入教职工信息(依次为编号、姓名、性别和职工类别,例如:0001 张明 m 实验员)"<<endl;cout<<"每次输入按c继续输入下一个,按n结束!"<<endl;cout<<""<<endl;for(i=0;i<500;i+)cout<<"请选择要输入的职工类别:"<<endl;cout<<"1.教师 2.实验员 3.行政人员 4.教师兼实验员 5.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 销售合作分成合同协议书
- 半挂车运输合同协议书
- 合同风险承担协议书范本
- 消防检测合同协议书范本
- 体检协议书模板合同字体
- 借贷解除合同协议书范本
- 2025年家具购销合同书
- 2025年上海车牌交易合同
- 合约合同协议书怎么写的
- 代持股协议书合同效力
- 吉林省工程竣工验收报告
- 手外伤及断肢(指)再植(讲稿)
- 新版心肺复苏流程图
- DB32/T 4444-2023 单位消防安全管理规范-高清版
- 初三物理滑轮习题
- 东南大学医学三基考试外科选择题及答案
- (2.1.1)-第2章颚式破碎机
- GB/T 9724-2007化学试剂pH值测定通则
- 拓展训练项目孤岛求生游戏规则与分享参考范本
- DS6-K5B计算机联锁演示教学课件
- 2022年成都信息工程大学计算机科学与技术专业《操作系统》科目期末试卷A(有答案)
评论
0/150
提交评论