欢迎来到天天文库
浏览记录
ID:52441285
大小:17.57 KB
页数:5页
时间:2020-03-27
《公司雇员java试题公.docx》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、§某公司的雇员分为以下若干类:§Employee:这是所有员工总的父类,属性:员工的姓名和生日月份。§方法:getSalary(intmonth)根据参数月份来确定工资,如果该月员工过生日,§则公司会额外奖励100元。§SalariedEmployee:Employee的子类,拿固定工资的员工。属性:月薪§HourlyEmployee:Employee的子类,按小时拿工资的员工,每月工作超出160§小时的部分按照1.5倍工资发放§属性:每小时的工资、每月工作的小时数§SalesEmployee:Employee的子类,销售人员,工资由月销售额和提成
2、率决定§属性:月销售额、提成率§BasePlusSalesEmployee:SalesEmployee的子类,有固定底薪的销售人员,§工资由底薪加上销售提成部分属性:底薪。classEmployee{privateStringname;privateintbirthmonth;publicEmployee(){}publicEmployee(Stringname,intbirthmonth){this.setName(name);this.setBirthmonth(birthmonth);}publicvoidsetName(Stringname
3、){this.name=name;}publicStringgetName(){returnname;}publicvoidsetBirthmonth(intbirthmonth){this.birthmonth=birthmonth;}publicintgetBirthmonth(){returnbirthmonth;}publicintgetSalary(intmonth){if(month==this.getBirthmonth()){return100;}elsereturn0;}publicvoidprint(){System.out.p
4、rint("该员工信息:"+"姓名:"+this.getName()+"出生月份:"+this.getBirthmonth()+"月工资:");}}classSalaryEmployeeextendsEmployee{privateintsalary;publicSalaryEmployee(Stringname,intbirthmonth,intsalary){super(name,birthmonth);setSalary(salary);}publicintgetSalary(){returnsalary;}publicvoidsetSala
5、ry(intsalary){this.salary=salary;}publicintgetSalary(intmonth){returnthis.salary+super.getSalary(month);}}classHourlyEmployeeextendsEmployee{privateinthour;privateintsalary;publicHourlyEmployee(Stringname,intbirthmonth,intsalary,inthour){super(name,birthmonth);setSalary(salary
6、);setHour(hour);}publicintgetHour(){returnhour;}publicvoidsetHour(inthour){this.hour=hour;}publicintgetSalary(){returnsalary;}publicvoidsetSalary(intsalary){this.salary=salary;}publicintgetSalary(intmonth){if(hour>160){return(int)(this.salary*160+(this.hour-160)*this.salary*1.
7、5+super.getSalary(month));}else{return(int)(this.salary*this.hour+super.getSalary(month));}}}classSalesEmployeeextendsEmployee{privateintsale;privatefloatcommission;publicSalesEmployee(){}publicSalesEmployee(Stringname,intbirthmonth,intsale,floatcommission){super(name,birthmon
8、th);setSale(sale);setCommission(commission);}publicintgetSale
此文档下载收益归作者所有