📄 employee.cpp
字号:
#include<iostream.h>
#include"employee.h"
Boss::Boss(char *p,float s):Employee(p)
{
weeklySalary=s>0? s:0;
}
void Boss::setweeklySalary(float s)
{
weeklySalary=s>0?s:0;
}
float Boss::Earnings()
{
return weeklySalary;
}
void Boss::Print()
{
cout<<"Boss:"<<Getname()<<endl;
}
CommissionWorker::CommissionWorker(char *p,float s,float c,int q):Employee(p)
{
Salary=s>0?s:0;
Commission=c>0?c:0;
Quantity=q>0?q:0;
}
void CommissionWorker::Set(float s, float c, int q)
{
Salary=s; Commission=c; Quantity=q;
}
float CommissionWorker::Earnings()
{ return (Salary+Commission*Quantity); }
void CommissionWorker::Print()
{
cout<<"Commissionworker:"<<Getname()<<endl;
}
PieceWorker::PieceWorker(char *p,float w,int q):Employee(p)
{
WagePerPiece=w>0?w:0;
Quantity=q>0?q:0;
}
void PieceWorker::Set(float w, int q)
{
WagePerPiece=w; Quantity=q;
}
float PieceWorker::Earnings()
{ return (WagePerPiece*Quantity); }
void PieceWorker::Print()
{
cout<<"PieceWorker:"<<Getname()<<endl;
}
hourlyWorker::hourlyWorker(char *p,float w,int h):Employee(p)
{
wage=w>0?w:0;
hours=h>0?h:0;
}
void hourlyWorker::set(float w,int h)
{
wage=w>0?w:0;
hours=h>0?h:0;
}
float hourlyWorker::Earnings()
{
if(hours<=40)
return (wage*hours);
else
return (40*wage+1.5*wage*(hours-40));
}
void hourlyWorker::Print()
{
cout<<"hourlyWorker:"<<Getname()<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -