版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
一、设计内容与设计要求
1.课程设计目的:
面向对象程序设计课程设计是集中实践性环节之一,是学习完《面向对象程序设计》
课程后进行的一次全面的综合练习。要求学生达到熟练掌握C++语言的基本知识和技能;
基本掌握面向对象程序设计的思想和方法;能够利用所学的基本知识和技能,解决简单
的面向对象程序设计问题,从而提高动手编程解决实际问题的能力。
2.课题题目
1)公司库存管理系统
2)高校学籍管理系统
3)高校工资管理系统
4)高校人事管理系统
5)通讯录程序设计
6)学生成绩管理系统
7)图书管理系统
8)文本编辑器的设计与实现
9)学生考勤管理系统
10)公司人员管理系统
3.设计要求:
⑴设计课题题目:每位同学根据自己学号除以9所得的余数加一选择相
应题号的课题。换题者不记成绩。(课题10只做为参考课题)
⑵根据自己对应的课题完成以下主要工作:①完成系统需求分析:包括
系统设计目的与意义;系统功能需求(系统流程图);输入输出的要求。②完
成系统总体设计:包括系统功能分析;系统功能模块划分与设计(系统功能模
块图)。③完成系统详细设计:包括数据库需求分析;数据库概念结构设计(E
—R图);数据库逻辑结构设计;类层次图;界面设计与各功能模块实现。④系
统调试:调试出现的主要问题,编译语法错误及修改,重点是运行逻辑问题修
改和调整。⑤使用说明书及编程体会:说明如何使用你编写的程序,详细列出
每一步的操作步骤。⑥关键源程序(带注释)
⑶按规定格式完成课程设计报告,将其打印稿(A4纸)上交给老师存档。
(4)不得抄袭他人程序、课程设计报告,每个人应体现自己的个性设计。
进度安排
第18周星期一8:00—-12:00
星期二8:00—-12:00
星期四8:00—-12:00
第19周星期一8:00—-12:00
星期二14::30-—18::30
星期三8:00—-12:00
三、参考书籍
1.《C++程序设计课程设计》刘振安编著TP312c563
2.《C++Builder和Delphi课程设计与系统开发案例》伍俊良清华大学出版社
7-302-06072-X
3.VisualC++课程设计案例精编严华峰中国水利水电出版社7-5084-2007T
2004
4.VisualC++课程设计与系统开发案例伍俊良清华大学出版社7-302-05968-3
2002
(编程平台不限,vc++,C++Builder等等。)
课题4:高校人事管理系统
(一)、课程设计题目:
高校人事管理系统
(二)、目的与要求:
1、目的:
(1)要求学生达到熟练掌握C++语言的基本知识和技能;
(2)基本掌握面向对象程序设计的基本思路和方法;
(3)能够利用所学的基本知识和技能,解决简单的面向对象程序设计问题。
2、基本要求:
(1)要求利用面向对象的方法以及C++的编程思想来完成系统的设计;
(2)要求在设计的过程中,建立清晰的类层次;
(3)在系统中至少要定义四个类,每个类中要有各自的属性和方法;
(4)在系统的设计中,至少要用到面向对象的一种机制。
3、创新要求:
在基本要求达到后,可进行创新设计,如根据查找结果进行修改的功能。
4、写出设计说明书
(三)、设计方法和基本原理:
1、问题描述(功能要求):
某高校,主要人员有:在职人员(行政人员、教师、一般员工)、退休人员、返聘
人员和临时工。现在,需要存储这些人员的人事档案信息:编号、姓名、性别、年龄、
职务、职称、政治面貌、最高学历、任职时间、来院时间。
要求:
(1)添加删除功能:能根据学院人事的变动情况,添加删除记录;
(2)查询功能:能根据编号和姓名进行查询;
(3)编辑功能(高级):根据查询对相应的记录进行修改,并存储;
(4)统计功能:能根据多种参数进行人员的统计(在职人数、党员人数、女工人
数、高学历高职称人数);
(5)保存功能:能对输入的数据进行相应的存储,要求重载插入和提取符以完成
数据的保存和打开。
(6)人员编号在生成人员信息时同时生成,每输入一个人员信息编号顺序加1。
2、问题的解决方案:
根据系统功能要求,可以将问题解决分为以下步骤:
(1)应用系统分析,建立该系统的功能模块框图以及界面的组织和设计;
(2)分析系统中的各个实体及它们之间的关系包括属性和行为;
(3)根据问题描述,设计系统的类层次;
(4)完成类层次中各个类的描述(包括属性和方法);
(5)完成类中各个成员函数的定义;
(6)完成系统的应用模块;
(7)功能调试;
(8)完成系统总结报告以及系统使用说明书。
目录
1.系统需求分析...................................................-1-
2.总体设计.........................................................2
3.详细设计.........................................................3
4.系统调试.........................................................4
5.结果分析.........................................................4
6.总结...............................................................7
1.系统需求分析
题目需求:
(1)添加删除功能:能根据学院人事的变动情况,添加删除记录;
(2)查询功能:能根据编号和姓名进行查询;
(3)编辑功能(高级):根据查询对相应的记录进行修改,并存储;
(4)统计功能:能根据多种参数进行人员的统计(在职人数、党员人数、女工人数、
高学历高职称人数);
(5)保存功能:能对输入的数据进行相应的存储,要求重载插入和提取符以完成数
据的保存和打开。
(6)人员编号在生成人员信息时同时生成,每输入一个人员信息编号顺序加1。
系统设计目标:
(1)系统能根据用户输入菜单的选项进行执行。
(2)能对基本错误进行判断,并要求用重新输入。
(3)能够把输入的数据保存到txt文件中,下次能够使用。
(4)有较好的人性化,不至于用户不知道做什么。
系统实现功能:
(1)删除功能:能根据用户输入姓名与编号进行删除。
(2)查询功能:能根据用户输入姓名、编号、职位、来校时间、离校时间。
(3)编辑功能:能根据查询的数据进行修改。
(4)统计功能:能根据多种参数进行人员统计。
(5)保持功能:能对输入的数据进行存储在文件中。
(6)识别错误功能:能对基本错误进行判断,并要求用户重新输入。
⑺人员编号在生成人员信息时自动生成。
湖南工程学院课程设计报告
2.总体设计
系统功能模块划分
-2-
湖南工程学院课程设计报告
3.详细设计
UML:
Time
ToSchoolTime
-numbert:int
—►-Work:work;
----►-ToSchoolTime:toSchoolTime
-LeaveSchoolTime:leaveSchoolTime
-WorkTime:workerTime◄-----
-judgeLeaveSchol:char
+Worker(j=,N,:char)
+〜Worker。
+«const»getNum():int
-----a+«const»getWork():Work
__>+«const»getToSchoolTime():ToSchoolTime
+«const»getLeaveSchoolTime():LeaveSchoolTime<
+«const»getWorkTime():WorkTime◄------------------------
+«const»getJudgeLeaveSchool():char
+setNum(n:int&):void
------>+setWork(w:Work&):void
------►+setToSchoolTime(t:ToScholTime&):void
+setLeaveSchoolTime(l:LeaveSchoolTime&):void◄-
+setWorkTime(w:WorkTime&):void-----------------------------------
+setJudgeLeaveSchool(j:char&):void
+«virtual»input():void
+«friend»operator«(out:ostream,worke亡constWorker&):ostream
+«friend»operator»(input:istream,worker:constWorker&):istream
Work
湖南工程学院课程设计报告
4.系统调试
1.问题1:VC++6.0对友元函数支持不是很好,通过查资料得知解决方法。
2.问题2:逻辑错误,通过分析解决。
3.问题3:txt文件读入到动态数组中去,会读错,读不出,多读入一个,通过询问
老师同学解决。
4.问题4:vector容器中成员函数的使用,通过查书解决。
5.结果分析
1.输入信息
2.查询信息
1:按姓名查询
2:按编号查询
-4-
湖南工程学院课程设计报告
3:按来校时间查询
4:按离校时间查询
5:按职工职位查询
3:删除信息
1:按姓名删除
2:按编号删除
4:编辑信息
3:增加职工
湖南工程学院课程设计报告
5:统计信息
6:输出信息
0:退出系统
独到的设计:
1.有基本的纠错功能,并能提示用户重新输入。
2.除了按姓名、编号搜索还能按来小时间、离校时间、职位进行搜索。
3.编辑功能能够分别对姓名、编号、性别、修改。
4.较好的使用继承、派生,符合基本思维。
5.较好的使用类的组合。
6.函数命名、类的命名、数据的命名能够见明思意,较好的符合命名规则。
不足之处:
1.源代码过多,仅仅使用了容器vector,没有使用STL迭代器、算法等。
2.基类没有很好的抽象。
3.主函数调用的函数没有封装在一个类中,仅仅包含在一个头文件中。
-6-
湖南工程学院课程设计报告
4.文件的操作没有很好的掌握。
5.数据输出,没有按格式对齐混乱。
6.函数过长,函数做的事情不止一件。
7.类中包含的成员过多。
8.不够人性话,用户界面不够美观。
9.对于一些错误不能有效的终止。
(总结自己独到的设计特点和不足之处。)
6.总结
通过一-周的课程设计,我学到了很多东西,
1.系统分析,类层次之间的关系非常重要,只有架构好总体,才能设计出好
的系统
2.建立了一套完整的系统模型,先从整体入手,再细分。而不是一开始就着
急编写,那样系统只会非常混乱。
3.函数、类的命名。基本上能够见名思意。
4..文件的操作本来是一片模糊,通过实践操作,已经理解对文件的操作,原来
很简单。
5.通过与同学讨论,知道要擅长使用STL来解决实际问题,而不是自己去编
写函数。懂得利用C++中定义的对象解决问题。对于面向对象设计又有了更深
的理解。
6.类之间的设计中符合人的思维逻辑。
7.通过一些书籍,知道在设计中要遵守的规则,程序中统一的输出格式。
8.知道一些基本的优化规则,如函数只能做一件事、越小越好、基类要足够
的抽象,最好使用组合而不是继承,减少依赖性等等。
9.在程序设计中要与别人合作,把自己的糟粕去掉,吸取别人程序中的精华,
与其他同学讨论。
10.编写中要先写好一个功能后马上调试,及时发现问题,及时解决问题,而
不是系统写完后再慢慢调试,那样问题会很多,调好这里后那里又出现问题,
我们初学者还有很多细节不会注意,这种方法有助于我更快的编写出系统,减
-7-
湖南工程学院课程设计报告
少编写时间,把更多的时间留下来完善程序。
总之,通过这次的课程设计,让我真正了解到C++语言中的类模块真正魅力和无穷的
功能,感到STL的强大,希望尽快掌握STL的知识来解决实际问题。通过对文件的操
作领略到编程的神奇,感到非常的方便。这个学期的对C++的学习,仅仅是叩开了C++
这扇大门,里面还有很多知识我所不知道的,而此次的课程设计更加激发了我对C++
语言学习的浓厚兴趣。这个假期会进一步加强这个学期所学,也会进一步学习C++。
-8-
计算机与通信学院课程设计评分表
课程名称:血向对象程序设计
项目评价
设计方案的合理性与创造性
设计与调试结果
设计说明书的质量
答辩陈述与回答问题情况
课程设计周表现情况
综合成绩
教师签名:______________
H期:______________
附源代码:
Time.h
#ifndefTIME_H
#defineTIME.H
classTime
(
public:
Time(inty=1900,intm=l,intd=l);
virtual~Time();
intgetYear()const;
intgetMonth()const;
intgetDayOconst;
voidsetYear(inty);
voidsetMonth(intm);
voidsetDay(intd);
booljudgeLeapYear();
protected:
intyear;
intmonth;
intday;
);
#endif
Time.cpp
#include<iostream>
usingnamespacestd;
#includeHTime.hn
Time::Time(inty,intm,intd):year(y),month(m),day(d)
(
)
Time::~Time()
(}
-2-
intTime::getYear()const
{returnyear;}
intTime::getMonth()const
{returnmonth;}
intTime::getDay()const
{returnday;}
voidTime::setYear(inty)
{year=y;}
voidTime::setMonth(intm)
{month=m;}
voidTime::setDay(intd)
{day=d;}
boolTime::judgeLeapYear()
(
boolflag=true;
flag=((year%4==0)&&(year%100!=0)II(year%400==0));
returnflag;
)
ToSchooITime.h
#ifndefTOSCHOOLTIME.H
#defineTOSCHOOLTIME.H
#include"Time.hM
classToSchoolTime:publicTime
(
public:
ToSchoolTime(inty=1900,intm=l,intd=l);
virtual-ToSchoolTime();
booljudgeYear();
voidinputYearQ;
booljudgeMonth();
voidinputMonth();
-3-
intjudgeMonthDay();
booljudgeDayO;
voidinputDay();
voidinputlbSchoolTime();
friendostream&operator«(ostream&out,constIbSchoolTime&t)
(
out«n”;
out«t.year«"-n«t.month«,,-',«t.day;
returnout;
}
friendistream&operator»(istream&input,IbSchoolTime&t)
(
charcl,c2;
input»t.year»cl»t.month»c2»t.day;
returninput;
)
private:
intoneMonthDay;
);
#endif
ToSchoolTime.cpp
#include<iostream>
usingnamespacestd;
#includenToSchoolTime.h,'
#includenTime.hn
ToSchoolTime::ToSchoolTime(inty,intm,intd):Time(y,m,d)
{oneMonthDay=30;}
ToSchoolTime::^ToSchoolTime()
()
boolToSchoolTime:JudgeYear()
{constintstartYear=1990;
-4-
boolflag=true;
if(year<startYear)
(
flag=false;
cout«n\t输入有误,起始年份大于来校年份:"vvstartYearvv”>H«year«endl;
)
returnflag;
)
voidToSchoolTime::inputYear()
(
boolflag=false;
while(!flag)
(
cout«n###来校年份###(1990〜?):";
cin»year;
flag=judgeYear();
)
cout«endl;
)
boolToSchoolTime::judgeMonth()
{
boolflag=true;
constintstartMonth=l;
constintendMonth=12;
if(month<1IImonth>12)
{
flag=false;
cout«n\t输入有误,一年中没有“vvmonthvv”月份kvendl;
)
returnflag;}
-5-
voidToSchoolTime::inputMonth()
boolflag=false;
while(!flag)
(
cout«n###来校月份###(1~12):
cin»month;
flag=judgeMonth();
)
cout«endl;
)
intToSchoolTime::judgeMonthDay()
(
if(month==2)
{
boolflagYear=false;
flagYear=judgeLeapYear();
if(flagYear)
{oneMonthDay=29;}
else
{oneMonthDay=28;}
}
elseif(month<8)
(
if(month%2==0)
{oneMonthDay=30;}
else{oneMonthDay=31;}
)
else
if(month%2==0)
-6-
{oneMonthDay=31;}
else
{oneMonthDay=30;}
}returnoneMonthDay;
)
boolToSchoolTime::judgeDay()
(
boolflag=true;
constintstartDay=l;
constintendDay=oneMonthDay;
if(day<startDayIIday>oneMonthDay)
(
flag=false;
cout«"\t输入有误Jvvmonthvv"月份没有“vvdayvv“这一天“<vendl;
)
returnflag;
)
voidToSchoolTime::inputDay()
{oneMonthDay=judgeMonthDay();
boolflag=false;
while(!flag)
(
cout«"###来校日###(1〜n«oneMonthDay«n):
cin»day;
flag=judgeDay();
)
cout«endl;
voidToSchoolTime::inputToSchooITime()
{inputYearQ;
inputMonthQ;
-7-
inputDayO;}
LeaveSchoolTime.h
#ifndefLEAVESCHOOLTIME.H
#defineLEAVESCHOOETIME_H
#includenTime.hn
#includeHToSchoolTime.hn
classLeaveSchoolTime:publicTime
(
public:
LeaveSchoolTime(intyear=2010,intmonth=l,intday=l);
virtual-LeaveSchoolTime();
intgetOneMonthDayOconst;
voidinputYear(constint&toSchoolYear);
intjudgeLeaveSchoolYear(constint&toSchoolYear);
〃判断输入年份是否小于来校年份
intjudgeLeaveSchoolMonth(constint&toSchoolMonth);
〃当来校年份与离校年份相等时,判断输入月份是否小于来校月
intjudgeLeaveSchoolDay(constint&toSchoolDay);
voidinputMonth(constint&toSchoolYear,constint&toSchoolMonth);
intjudgeMonthDayO;〃判断一个月有多少天.
booljudgeDayOveroneMonthDay();
voidinputDay(constint&toSchoolYear,constint&toSchoolMonth,constint
&toSchoolDay);
voidinputLeaveSchoolTime(constToSchoolTime&toSchoolTime);
friendostream&operator«(ostream&out,constLeaveSchoolTime&1)〃友元函
数重载vv用来输出
LeaveSchoolTime类
out«l.year«,,-,,«l.month«,'-',«Lday;
returnout;
-8-
friendistream&operator»(istream&input,LeaveSchoolTime&1)〃友元函数重
载»用来输入
LeaveSchoolTime类
(
charcl,c2;
input»l.year»cl»Lmonth»c2»l.day;
returninput;
)
private:
intoneMonthDay;
);
#endif
LeaveSchool.cpp
#include<iostream>
usingnamespacestd;
#includenLeaveSchoolTime.hn
#include,,ToSchoolTime.hn
#includenTime.hn
LeaveSchoolTime::LeaveSchoolTime(intyear,intmonth,intday):Time(year,month,day)
{oneMonthDay=judgeMonthDay();}〃调用函数。
LeaveSchoolTime::-LeaveSchooITime()
()
intLeaveSchoolTime::getOneMonthDay()const
{returnoneMonthDay;}
intLeaveSchoolTime::judgeLeaveSchoolYear(constint&toSchoolYear)
{intflag=l;
if(toSchoolYear==year)
{flag=0;}
if(toSchoolYear>year)
-9-
flag=-l;
cout«M\t输入有误,来校年份大于离校年份:"vvtoSchoolYearvv”>
H«year«endl;
)
returnflag;
)
voidLeaveSchoolTime::inputYear(constint&toSchoolYear)
(
intflag=-l;
while(flag==-1)
(
cout«n###该职工离校的年份###(n«toSchoolYear«n-?):
cin»year;
flag=judgeLeaveSchoolYear(toSchoolYear);
)
cout«endl;
)
intLeaveSchoolTime::judgeLeaveSchoolMonth(constint&toSchoolMonth)
(
intflag=l;
if(toSchoolMonth==month)
{flag=0;}
if(toSchoolMonth>month)
{flag=-l;}
returnflag;
)
voidLeaveSchoolTime::inputMonth(constint&toSchoolYear,constint
&toSchoolMonth)
intflagYear=judgeLeaveSchoolYear(toSchoolYear);
-10-
if(flagYear==0)
intflagMonth=-1;
while(flagMonth==-1)
(
cout«n###离校月份###("«toSchoolMonth«"-12):
cin»month;
flagMonth=judgeLeaveSchoolMonth(toSchoolMonth);
)
)
else
(
cout«"###离校月份###(1〜12):“;
cin»month;
cout«endl;
intLeaveSchoolTime::judgeMonthDay()
(
oneMonthDay=30;
if(month==2)
(
boolflagYear=false;
flagYear=judgeLeapYear();
if(flagYear)
{oneMonthDay=29;}
else
{oneMonthDay=28;}
elseif(month<8)
-11-
if(month%2!=0)
{oneMonthDay=31;}
)
else
(
if(month%2==0)
{oneMonthDay=31;}
)
returnoneMonthDay;
)
intLeaveSchoolTime::judgeLeaveSchoolDay(constint&toSchoolDay)
(
intflag=l;
if(toSchoolDay==day)
(
flag=0;
)
elseif(toSchoolDay>day)
(
flag=-l;
cout«"\t输入有误,来校日大于离校日:"vvtoSchoolDayvv”>H«day«endl;
)
cout«endl;
returnflag;
)
boolLeaveSchoolTime::judgeDayOveroneMonthDay()
boolflag=true;
if(day>oneMonthDay)
-12-
flag=false;
cout«"\t输入有误:“《day<v”>n«oneMonthDay;
)
cout«endl;
returnflag;
)
voidLeaveSchoolTime::inputDay(constint&toSchoolYear,constint&toSchoolMonth,
constint&toSchoolDay)
(
oneMonthDay=judgeMonthDay();
intflagYear=judgeLeaveSchoolYear(toSchoolYear);
intflagMonth=judgeLeaveSchoolMonth(toSchoolMonth);
if(flagYear==0&&flagMonth==0)
(
boolflagOveroneMonthDay=false;
while(JflagOveroneMonthDay)
{
intflagDay=-l;
while(flagDay==-1)
(
cout«n###该职工离校日###(^^«toSchoolDay«^^〜
H«oneMonthDay«n):";
cin»day;
flagDay=judgeLeaveSchoolDay(toSchoolDay);
)
flagOveroneMonthDay=judgeDayOveroneMonthDay();
else
-13-
boolflagOveroneMonthDay=false;
while(JflagOveroneMonthDay)
(
cout«M###该职工离校日###(1-n«oneMonthDay«n):n;
cin»day;
flagOveroneMonthDay=judgeDayOveroneMonthDay();
)
)
cout«endl;
)
voidLeaveSchoolTime::inputLeaveSchoolTime(constToSchoolTime&toSchoolTime)
(
inputYear(toSchoolTime.getYear());
inputMonth(toSchoolTime.getYear(),toSchoolTime.getMonth());
inputDay(toSchoolTime.getYear(),toSchoolTime.getMonth(),
toSchoolTime.getDayO);
)
WorkTime.h
#include<iostream>
usingnamespacestd;
#ifndefWORKTIME_H
#defineWORKTIME_H
#include"Time.h"
#include"ToSchoolTime.hn
#include^^LeaveSchoolTime.h'^
classWorkTime:publicTime
(
public:
WorkTime();
virtual-WorkTime();
-14-
voidcalculateWorkTimeYear(constint&toSchoolYear,constint&leaveSchoolYear);
〃计算在职年份
voidcalculateWorkTimeMonth(constint&toSchoolMonth,constint
&leaveSchoolMonth);〃计算在职月份
voidcalculateWorkTimeDay(constint&toSchoolDay,constint&leaveSchoolDay);
〃计算在职天数
voidcalculateWorkTime(constToSchoolTime&toSchoolTime,const
LeaveSchoolTime&leaveSchoolTime);〃计算在职时间
voidisDayNegative(int&day);〃天数为负,则月份减一
voidisMonthNegative(int&month);
friendostream&operator«(ostream&out,constWorkTime&w)
〃友元函数重载vv输出在职时间
(
out«n,,«w.year«"-,,«w.month«,,-n«w.day;
returnout;
)
friendistream&operator»(istream&input,WorkTime&w)/友元函数重载》输
入在职时间
/(
charcl,c2;
input»w.year»c1»w.month»c2»w.day;
returninput;
)
private:
intoneMonthDay;
);
#endif
WorkTime.cpp
#include<iostream>
usingnamespacestd;
#includenTime.h"
-15-
#include,,ToSchoolTime.hn
#include,,LeaveSchoolTime.hn
#includenWorkTime.hn
WorkTime::WorkTime()
(}
WorkTime::-WorkTime()
()
voidWorkTime::calculateWorkTimeYear(constint&toSchoolYear,constint
&leaveSchoolYear)
{year=leaveSchoolYear-toSchoolYear;}
voidWorkTime::isMonthNegative(int&month)
(
if(month<0)
(
year=year-1;
month=month+12;
voidWorkTime::calculateWorkTimeMonth(constint&toSchoolMonth,constint
&leaveSchoolMonth)〃此处可分解
(
month=leaveSchoolMonth-toSchoolMonth;
isMonthNegative(month);
)
voidWorkTime::isDayNegative(int&day)
(
if(day<0)
month=month-1;
day=day+oneMonthDay;
-16-
voidWorkTime::calculateWorkTimeDay(constint&toSchoolDay,constint
&leaveSchoolDay)〃此处可分解
(
day=leaveSchoolDay-toSchoolDay;
if(day<0)
(
month=month-1;
day=day+30;
}
)
voidWorkTime::calculateWorkTime(constToSchoolTime&toSchoolTime,const
LeaveSchoolTime&leaveSchoolTime)
(
oneMonthDay=leaveSchoolTime.getOneMonthDay();
calculateWorkTimeYear(toSchoolTime.getYear(),leaveSchoolTime.getYear());
calculateWorkTimeMonth(toSchoolTime.getMonth(),leaveSchoolTime.getMonth());
calculateWorkTimeDay(toSchoolTime.getDay(),leaveSchoolTime.getDayO);
)
People.h
#ifndefPEOPLE_H
#definePEOPLE.H
classPeople
(
public:
People(stringn='*0n,chars=M\inta=20,intpl=2,intel=2);
virtual〜People。;
stringgetName()const;
chargetSexQconst;
intgetAge()const;
-17-
intgetPoliticalLandscape()const;
intgetEductionLevel()const;
voidsetName(stringn);
voidsetSex(chars);
voidsetAge(inta);
voidsetPoliticalLandscape(intp);
voidsetEductionLevel(inte);
booljudgePoliticalLandscapeCorrect();
booljudgeEductionLevelCorrect();
voidinputName();
voidinputSex();
voidinputAge();
voidinputPoliticalLandscape();
voidinputEductionLevel();
virtualvoidinput();
protected:
stringname;
charsex;
intage;
intpoliticalLandscape;
inteductionLevel;
};
#endif
People.cpp
#include<iostream>
#include<string>
usingnamespacestd;
#includenPeople.hM
People::People(stringn,chars,intajntpl,intel):name(n),sex(s),age(a),politicalLandscape(p
l),eductionLeveI(el)
()
-18-
People:>People()
()
stringPeople::getName()const
{returnname;}
charPeople::getSex()const
{returnsex;}
intPeople::getAge()const
{returnage;}
intPeople::getPoliticalLandscape()const
{returnpoliticalLandscape;}
intPeople::getEductionLevel()const
{returneductionLevel;}
voidPeople::setName(stringn)
{name=n;}
voidPeople::setSex(chars)
{sex=s;}
voidPeople::setPoliticalLandscape(intp)
{politicalLandscape=p;}
voidPeople::setEductionLevel(inte)
{eductionLevel=e;}
boolPeople::judgePoliticalLandscapeCorrect()
(
boolflag=true;
if(politicalLandscape<1IIpoliticalLandscape>3)
(
flag=false;
coutvv”输入有误,没有该项.请重新输入Jvvendl;
)
returnflag;
-19-
boolPeople::judgeEductionLevelCorrect()
boolflag=true;
if(eductionLevel>6IIeductionLevel<l)
(
flag=false;
coutvv”输入有误,没有该项.请重新输入Jvvendl;
)
returnflag;
)
voidPeople::inputName()
(
coutvv'职工姓名:”;
cin»name;
cout«endl;
)
voidPeople::inputSex()
(
cout«n###该职工性别###(男M,女W):";
cin»sex;
cout«endl;
)
voidPeople::inputAge()
(
cout«n###该职工年龄###:";
cin»age;
cout«endl;
)
voidPeople::inputPoliticalLandscape()
boolflagPolitical=false;
-20-
while(!flagPolitical)
cout«M###该职工政治面貌###:n«n\nH
vv”(l.群众2.团员3.党员)###请输入###<13>:
cin»politicalLandscape;
flagPolitical=judgePoliticalLandscapeCorrect();
)
cout«endl;
)
voidPeople::inputEductionLevel()
(
boolflagEduction=false;
while(!flagEduction)
(
cout«"###该职工最高学历###:"«"\n"
<<"(1.专科2.本科3.硕士4.博士5.博士后)###请输入###<1~5>:
cin»eductionLevel;
flagEduction=judgeEductionLevelCorrect();
)
cout«endl;
)
voidPeople::input()
(
inputName();
inputSex();
inputAge();
inputPoliticalLandscape();
inputEductionLevel();
)
Worker.h
#ifndefTEACHER_H
-21-
#defineTEACHER_H
#includenPeople.hn
#includenLeaveSchoolTime.hn
#includenToSchoolTime.hu
#includenWork.h"
#includenWorkTime.hn
classWorker:publicPeople
(
public:
Worker(charj=Y);
virtual〜Worker。;
intgetNum()const;
WorkgetWork()const;
LeaveSchoolTimegetLeaveSchoolTime()const;
ToSchoolTimegetToSchoolTime()const;
WorkTimegetWorkTime()const;
chargetJudgeLeaveSchooI()const;
voidgenerateNum(intn);
voidsetWork(constWork&w);
voidsetLeaveSchoolTime(constLeaveSchoolTime&1);
voidsetToSchoolTime(constToSchoolTime&t);
voidsetWorkTime(constWorkTime&w);
voidsetJudgeLeaveSchool(charj);
virtualvoidinput();
friendostream&operator«(ostream&out,constWorker&worker)
{
out.setf(ios::left);
out.width(15);
out«;
out.unsetf(ios::left);
out.width(7);
-22-
out«worker.number;
out.width(7);
out«worker.sex;
out.width(lO);
out«worker.age;
out.width(15);
switch(worker.politicalLandscape)
{
case1:
outvv”党员”;
break;
case2:
outv〈”团员”;
break;
case3:
outvv”党员”;
break;
)
out.width(12);
switch(ctionLevel)
(
case1:
outvv”专科”;
break;
case2:
out<<"本科";
break;
case3:
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年温州科技职业学院单招综合素质笔试参考题库附答案详解
- 2025山东德州临邑县人民医院招聘备案制工作人员15人备考题库附答案
- 2026青海省公务员考试常识判断专项练习题及答案1套
- 2026年时事政治测试题库100道附参考答案(夺分金卷)
- 2026年口腔正畸学考试题库100道及完整答案(名师系列)
- 2026年国际商务英语一级考试练习题100道附答案【预热题】
- 2026年国际商务英语一级考试练习题100道含完整答案【各地真题】
- 2026年石家庄职业技术学院单招综合素质考试参考题库附答案详解
- 大学生就业合同协议书
- 岗位调整补签合同协议
- 落地式钢管脚手架专项施工方案
- 2025年母子公司间投资合同范本
- 2026中央广播电视总台招聘参考笔试题库及答案解析
- 班玛县公安局招聘警务辅助人员考试重点题库及答案解析
- 2026年电厂运行副值岗位面试题及答案
- Q-CR 783.1-2021 铁路通信网络安全技术要求 第1部分:总体技术要求
- GB/T 36964-2018软件工程软件开发成本度量规范
- FZ/T 10007-2018棉及化纤纯纺、混纺本色纱线检验规则
- 普通高校学生转学申请确认表(模板)
- 口腔医院医疗纠纷及投诉处理接待制度
- 二年级上册英语期中考试试卷
评论
0/150
提交评论