面向对象程序设计实验3文档格式.docx
- 文档编号:7417485
- 上传时间:2023-05-08
- 格式:DOCX
- 页数:13
- 大小:49.94KB
面向对象程序设计实验3文档格式.docx
《面向对象程序设计实验3文档格式.docx》由会员分享,可在线阅读,更多相关《面向对象程序设计实验3文档格式.docx(13页珍藏版)》请在冰点文库上搜索。
Technician类派生的属性有每小时附加酬金和当月工作时数,以及研究完成进度系数,业绩工资为三者之积。
也包括同名的pay函数,工资总额为基本工资加业绩工资。
Saleman类派生的属性有当月销售额和酬金提取百分比,业绩工资为两者之积。
Manager类派生的属性有固定奖金额和业绩系数,业绩工资为两者之积。
工资总额也为基本工资加业绩工资。
而在developermanager类中,pay函数是将作为经理和作为技术人员业绩工资之和的一半作为业绩工资。
在salesmanager类中,pay函数则是经理的固定奖金额的一半,加上部门总销售额与提成比例之积,这是业绩工资。
编程实现工资管理。
特别注意pay()的定义和调用方法:
先用同名覆盖,再用运行时多态。
四、实验结果与数据处理
1:
2
五、分析与讨论
派生类的多态还是不熟练
六、教师评语
签名:
日期:
成绩
附件:
源代码
//leixingzhuanghuan.cpp:
实验8第1题
//
#include"
stdafx.h"
#include<
iostream.h>
classPartFilledArray
{
public:
PartFilledArray()
{number=0;
Array=newint[1];
}
PartFilledArray(intp)
{number=p;
Array=newint[p];
PartFilledArray(constPartFilledArray&
b1)//
{inti;
number=b1.number;
Array=newint[number];
for(i=0;
i<
number;
i++){Array[i]=b1.Array[i];
}
~PartFilledArray(){deleteArray;
int*Array,number;
};
classPartFileledArrayWMax:
publicPartFilledArray
PartFileledArrayWMax():
PartFilledArray()//1
{max_value=0;
PartFileledArrayWMax(intp):
PartFilledArray(p)//2
{set(p);
max_value=get_max(p);
voidset(intp)
{
inti;
cout<
<
"
请输入"
p<
个整数:
endl;
p;
i++){cin>
>
Array[i];
PartFileledArrayWMax(constPartFileledArrayWMax&
a1):
PartFilledArray(a1)//fuzhi
{max_value=a1.max_value;
~PartFileledArrayWMax(){}
intget_max(intnumber)const
{inti,p=0;
for(i=0;
i++){if(Array[i]>
p)p=Array[i];
}returnp;
voidadd_value(intp)
{int*q,i;
q=newint[number+1];
i++){q[i]=Array[i];
q[number]=p;
deleteArray;
Array=q;
number+=1;
if(p>
max_value)max_value=p;
voidoperator=(constPartFileledArrayWMax&
b1)
if(number<
b1.number)
{
deleteArray;
Array=newint[b1.number];
}
b1.number;
max_value=b1.max_value;
voidshow()const
{inti;
i++){cout<
Array[i]<
"
;
}cout<
MAX:
max_value<
private:
intmax_value;
intmain()
PartFileledArrayWMaxMlgB(10),wcl;
PartFileledArrayWMaxNnD(MlgB);
wcl=MlgB;
MlgB.show();
wcl.show();
NnD.show();
MlgB.add_value(11);
return0;
82.h
#ifndefshengjinbing
#defineshengjinbing
classemployee//雇员基础工资1000请假一天15工资级别1
employee();
set_name();
virtualvoidpay();
//输入请假天数,扣除应扣工资后,得出实发基本工资。
~employee(){deletexingming,zhigonghao;
protected:
char*xingming;
intgongzijibie,yuexin;
int*zhigonghao;
employee:
:
employee()//构造
{xingming=newchar[15];
zhigonghao=newint[10];
gongzijibie=1;
yuexin=0;
set_name()
{chartemp_i;
inti,temp_in;
cout<
请输入姓名(拼音):
temp_i=cin.get();
if(temp_i==10)temp_i=cin.get();
for(i=0;
temp_i!
=10;
i++,temp_i=cin.get())
{xingming[i]=temp_i;
xingming[i]='
\0'
请输入职工号(10位):
temp_in=cin.get();
if(temp_in==10)temp_in=cin.get();
temp_in!
i++,temp_in=cin.get())
{zhigonghao[i]=temp_in;
zhigonghao[i]='
voidemployee:
pay()//雇员employee的pay
{inttemp_qingjia;
charwuyong;
请输入请假天数:
cin>
temp_qingjia;
wuyong=cin.get();
yuexin=1000-15*temp_qingjia;
应发月薪为:
yuexin<
classmanager:
virtualpublicemployee//经理基础工资1500请假一天20工资级别2
manager():
employee()
{gudingjiangjine=0;
yejixishu=0;
yejigongzi_man=0;
voidset_man()
{charwuyong;
gongzijibie=2;
请输入固定奖金额:
gudingjiangjine;
请输入业绩系数:
cin>
yejixishu;
wuyong=cin.get();
yejigongzi_man=(int)gudingjiangjine*yejixishu;
voidpay()
{inttemp_qingjia;
set_man();
yuexin=1500+yejigongzi_man;
~manager(){}
intgudingjiangjine,yejigongzi_man;
floatyejixishu;
classtechnician:
virtualpublicemployee//技术人员基础工资1200请假一天20工资级别2
technician():
{fujiachoujin=0;
gongzuoshishu=0;
yanjiujindu=0;
yejigongzi_tec=0;
voidset_tec()
请输入每小时附加酬金:
fujiachoujin;
请输入当月工作时数:
gongzuoshishu;
请输入研究完成进度系数:
yanjiujindu;
yejigongzi_tec=(int)fujiachoujin*gongzuoshishu*yanjiujindu;
set_tec();
yuexin=1200+yejigongzi_tec;
~technician(){}
intfujiachoujin,gongzuoshishu,yejigongzi_tec;
floatyanjiujindu;
classsaleman:
virtualpublicemployee//销售员基本工资1000
saleman():
{xiaoshoue=0;
choujintiqu=0;
yejigongzi_sal=0;
voidset_sal()
请输入当月销售额:
xiaoshoue;
请输入酬金提取百分比:
choujintiqu;
yejigongzi_sal=int(xiaoshoue*choujintiqu);
{set_sal();
yuexin=1000+yejigongzi_sal;
~saleman(){}
intxiaoshoue,yejigongzi_sal;
floatchoujintiqu;
classdevelopermanager:
publicmanager,publictechnician//开发部经理既是经理也是技术人员
developermanager():
manager(),technician()
{yejigongzi_dev=0;
voidset_dev(){set_man();
set_tec();
{set_dev();
yejigongzi_dev=(yejigongzi_man+yejigongzi_tec)/2;
yuexin=1800+yejigongzi_dev;
~developermanager(){}
intyejigongzi_dev;
classsalesmanager:
publicmanager,publicsaleman//销售部经理既是经理也是销售员
salesmanager():
manager(),saleman()
{yejigongzi_sam=0;
zongxiaoshoue=0;
ticheng=0;
voidset_sam(){set_man();
set_sal();
{set_sam();
请输入部门总销售额:
zongxiaoshoue;
请输入提成比例:
ticheng;
yejigongzi_sam=gudingjiangjine/2+zongxiaoshoue*ticheng;
yuexin=1800+yejigongzi_sam;
~salesmanager(){}
intyejigongzi_sam,zongxiaoshoue,ticheng;
#endif
82.cpp
82.h"
voidfunpay(employee*ptr)
{ptr->
pay();
{employee*p;
雇员:
employeeb1;
p=&
b1;
funpay(p);
经理:
managerb2;
b2;
技术人员:
technicianb3;
b3;
销售员:
salemanb4;
b4;
开发部经理:
developermanagerb5;
b5;
销售部经理:
salesmanagerb6;
b6;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 面向 对象 程序设计 实验
![提示](https://static.bingdoc.com/images/bang_tan.gif)