ImageVerifierCode 换一换
格式:DOCX , 页数:48 ,大小:23.73KB ,
资源ID:23963832      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/23963832.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(用多态性实现工资发放系统 源代码.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

用多态性实现工资发放系统 源代码.docx

1、用多态性实现工资发放系统 源代码#ifndef HEADER_KESHE1#define HEADER_KESHE1class Birthdate unsigned year,month;public: Birthdate(unsigned=1900,unsigned=01); void SetYear(unsigned); void SetMonth(unsigned); unsigned GetYear() const; unsigned GetMonth() const; friend ostream& operator(ostream& out, Birthdate& b) retur

2、n outsetw(6) b.year / setw(2) setfill(0)(istream& in,Birthdate& b) string buf; in buf; b.SetYear(atoi(buf.substr(0,4).c_str(); b.SetMonth(atoi(buf.substr(5,2).c_str(); return in; friend ofstream& operator(ofstream& fout, Birthdate& b) fout setfill( )b.GetYear() /; fout setw(2)setfill(0)b.GetMonth()(

3、ifstream& fin,Birthdate& b) string buf; fin buf; b.SetYear(atoi(buf.substr(0,4).c_str(); b.SetMonth(atoi(buf.substr(5,2).c_str(); return fin; ;#endif#include#include#include#includeusing namespace std;#includekeshe1.hBirthdate:Birthdate(unsigned y,unsigned m) year=y; month=m;void Birthdate:SetYear(u

4、nsigned y) year=y;void Birthdate:SetMonth(unsigned m) month=m;unsigned Birthdate:GetYear()const return year;unsigned Birthdate:GetMonth()const return month;#ifndef HEADER_KESHE2#define HEADER_KESHE2#includekeshe1.hclass Employee unsigned ID; string name; Birthdate bir; string type; bool reward; bool

5、 draw; public: Employee(unsigned i,string,Birthdate,string); Employee(Employee& ); void SetName(string); void SetBirth(unsigned,unsigned); void SetBirth(Birthdate b); void SetType(string); void SetReward(bool); void SetDraw(bool); void SetID(unsigned); unsigned GetId() const; string GetName() const;

6、 Birthdate GetBirthday() const; string GetType() const; bool GetReward(unsigned) const; bool GetDraw() const; virtual double Pay() const return 0; virtual void Display() ; virtual void writeoffile(ofstream& fout) ; ;#endif#include#include#include#includeusing namespace std;#includekeshe2.hEmployee:E

7、mployee(unsigned i,string n,Birthdate b,string t):bir(b) ID=i; name=n; type=t; reward=0; draw=0;Employee:Employee(Employee& e) ID=e.ID; name=e.name; type=e.type; reward=e.reward; draw=e.draw; bir=e.bir;void Employee:SetName(string n) name=n;void Employee:SetBirth(unsigned y,unsigned m) bir.SetYear(y

8、); bir.SetMonth(m);void Employee:SetBirth(Birthdate b) bir=b;void Employee:SetType(string t) type=t;void Employee:SetReward(bool r) reward=r;void Employee:SetDraw(bool d) draw=d;void Employee:SetID(unsigned id) ID=id;unsigned Employee:GetId()const return ID;string Employee:GetName()const return name

9、;Birthdate Employee:GetBirthday()const return bir;string Employee:GetType()const return type;bool Employee:GetReward(unsigned m)const if(m=bir.GetMonth() return 1; return reward;bool Employee:GetDraw()const return draw;void Employee:Display() coutsetfill(0)setw(6)ID; coutsetfill( )setw(6)namesetw(7)

10、bir.GetYear()/setw(2)bir.GetMonth()setw(6)typesetw(10);void Employee:writeoffile(ofstream& fout) foutsetfill(0)setw(6)ID ; foutsetfill( )namesetw(8)bir.GetYear() bir.GetMonth()setw(8)typesetw(8)drawsetw(8);#ifndef HEADER_KESHE3#define HEADER_KESHE3#includekeshe2.hclass SalariedEmployee:virtual publi

11、c Employee int leaveday; double salary; public: SalariedEmployee(unsigned ,string,Birthdate,string,int,double); SalariedEmployee(Employee& ,int ,double); void SetLeaveDay(int); void SetSalary(double); int GetLeaveDay() const; double GetSalary() const; virtual double Pay() const; virtual void Display

12、() ; virtual void writeoffile(ofstream& fout) ; ;#endif#include#include#include#include#includeusing namespace std;#includekeshe3.hSalariedEmployee:SalariedEmployee(unsigned i,string n,Birthdate b,string t,int l=0,double s=3000):Employee(i,n,b,t) leaveday=l; salary=s;SalariedEmployee:SalariedEmploye

13、e(Employee& e,int l,double s ):Employee(e) leaveday=l; salary=s;void SalariedEmployee:SetLeaveDay(int l) leaveday=l;void SalariedEmployee:SetSalary(double s) salary=s;int SalariedEmployee:GetLeaveDay()const return leaveday;double SalariedEmployee:GetSalary()const return salary;double SalariedEmploye

14、e:Pay()const unsigned m; SYSTEMTIME sys; GetLocalTime(&sys); m=sys.wMonth; if(GetReward(m) return (salary+30*leaveday+200); else return salary+30*leaveday;void SalariedEmployee:Display() unsigned m; cout*固定薪金职员*endl; coutsetw(6)编号setw(6)姓名setw(10)出生年月setw(6)工种setw(10)奖励薪金setw(10); cout固定月薪setw(10)请假

15、天数setw(6)应扣setw(10)实发工资setw(10)是否领取endl; Employee:Display(); SYSTEMTIME sys; GetLocalTime(&sys); m=sys.wMonth; if(GetReward(m) cout200; else cout0; coutsetw(10)salarysetw(10)leavedaysetw(6)leaveday*30setw(10)Pay()setw(10); if(GetDraw() cout是endl; else cout否endl;void SalariedEmployee:writeoffile(ofst

16、ream& fout) foutG setw(8); Employee:writeoffile(fout); foutsetw(8)salarysetw(8)leavedayendl;#ifndef HEADER_KESHE4#define HEADER_KESHE4#includekeshe3.hclass HourlyEmployee:public Employee int hour; double sperhour; public: HourlyEmployee(unsigned ,string,Birthdate,string,int,double); HourlyEmployee(E

17、mployee&,int ,double ); void SetHour(int); void SetSperHour(double); int GetHour() const; double GetSperHour() const; virtual double Pay() const; virtual void Display() ; virtual void writeoffile(ofstream& fout); ;#endif#include#include#include#include#includeusing namespace std;#includekeshe4.hHour

18、lyEmployee:HourlyEmployee(unsigned i,string n,Birthdate b,string t,int h,double s):Employee(i,n,b,t) hour=h; sperhour=s;HourlyEmployee:HourlyEmployee(Employee& e,int h,double s):Employee(e) hour=h; sperhour=s;void HourlyEmployee:SetHour(int h) hour=h;void HourlyEmployee:SetSperHour(double s) sperhou

19、r=s;int HourlyEmployee:GetHour()const return hour;double HourlyEmployee:GetSperHour()const return sperhour;double HourlyEmployee:Pay()const unsigned m; SYSTEMTIME sys; GetLocalTime(&sys); m=sys.wMonth; if(GetReward(m) return (sperhour*160+sperhour*1.5*(hour-160)+200); else return (sperhour*160+sperh

20、our*1.5*(hour-160);void HourlyEmployee:Display() unsigned m; cout*计时职员*endl; coutsetw(6)编号setw(6)姓名setw(10)出生年月setw(6)工种setw(10)奖励薪金setw(10); cout工作时长setw(6)时薪setw(10)加班时长setw(10)实发工资setw(10)是否领取endl; Employee:Display(); SYSTEMTIME sys; GetLocalTime(&sys); m=sys.wMonth; if(GetReward(m) cout200; else

21、 cout0; coutsetw(10)hoursetw(6)sperhoursetw(10)hour-160setw(10)Pay()setw(10); if(GetDraw() cout是endl; else cout否endl;void HourlyEmployee:writeoffile(ofstream& fout) foutJ setw(8); Employee:writeoffile(fout); foutsetw(8)hoursetw(8)sperhourendl;#ifndef HEADER_KESHE5#define HEADER_KESHE5#includekeshe4.

22、hclass CommisionEmployee:virtual public Employee double sale; double ratio; public: CommisionEmployee(unsigned ,string,Birthdate,string,double,double); CommisionEmployee(Employee&,double,double); void SetSale(double); void SetRatio(double); double GetSale() const; double GetRatio() const; virtual do

23、uble Pay() const; virtual void Display() ; virtual void writeoffile(ofstream& fout) ; ;#endif#include#include#include#include#includeusing namespace std;#includekeshe5.hCommisionEmployee:CommisionEmployee(unsigned i,string n,Birthdate b,string t,double s,double a):Employee(i,n,b,t) sale=s; ratio=a;C

24、ommisionEmployee:CommisionEmployee(Employee& e,double s,double a):Employee(e) sale=s; ratio=a;void CommisionEmployee:SetSale(double s) sale=s;void CommisionEmployee:SetRatio(double a) ratio=a;double CommisionEmployee:GetSale()const return sale;double CommisionEmployee:GetRatio()const return ratio;do

25、uble CommisionEmployee:Pay()const unsigned m; SYSTEMTIME sys; GetLocalTime(&sys); m=sys.wMonth; if(sale30000) if(GetReward(m) return (sale*ratio-(30000-sale)*(2.0/1000)+200); else return (sale*ratio-(30000-sale)*(2.0/1000); else if(GetReward(m) return (sale*ratio+200); else return sale*ratio; void C

26、ommisionEmployee:Display() unsigned m; cout*普通销售员*endl; coutsetw(6)编号setw(6)姓名setw(10)出生年月setw(6)工种setw(10)奖励薪金setw(8); cout销售额setw(10)提成比例setw(8)应扣setw(10)实发工资setw(10)是否领取endl; Employee:Display(); SYSTEMTIME sys; GetLocalTime(&sys); m=sys.wMonth; if(GetReward(m) cout200; else cout0; coutsetw(8)salesetw(10)ratiosetw(8); if(sale30000) cout(30000-sale)*(2.0/1000)setw(10)Pay()setw(4); else cout0setw(10)Pay()setw(4); if(GetDraw() cout是endl; else cout否

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1