ar;
ianCalendar;
publicclassEmployee{
/**
*Employee:这是所有员工总的父类,属性:员工的姓名和生日月份。方法:getSalary(int
month)根据参数月份来确定工资,
*如果该月员工过生日,则公司会额外奖励100元。
*/
privateStringname;
protectedintmonth;
privateintba=6000;
privateintsalary;
publicEmployee(){
}
publicEmployee(Stringname,intmonth){
e(name);
th(month);
}
publicStringgetName(){
returnname;
}
publicvoidtName(Stringname){
=name;
}
publicintgetMonth(){
returnmonth;
}
publicvoidtMonth(intmonth){
=month;
}
GregorianCalendarg=newGregorianCalendar();
intflag=(int)()+1;
publicintgetSalary(intmonth){
ints=th();
if(flag==s){
salary=ba+100;
}el
salary=ba;
returnsalary;
}
voidsays(){
n("当前月份:"+flag);
}
}
//SalaryEmployee:Employee的子类,拿固定工资的员工。属性:月薪
classSalaryEmployeeextendsEmployee{
privateintba=6000;
privateintsalary;
publicSalaryEmployee(Stringname,intmonth){
super(name,month);
}
publicintgetSalary(intmonth){
ints=th();
if(flag==s){
salary=ba+100;
}el{
salary=ba;
}
returnsalary;
}
voidsays(){
n(""+"姓名:"+e()+""+"生日所在月:"
+th()+""+"所得薪酬:"+getSalary(month));
}
}
//HourlyEmployee:Employee的子类,按小时拿工资的员工,每月工作超出160小时的部分
按照1.5倍工资发放。
//属性:每小时的工资、每月工作的小时数
classHourlyEmployeeextendsEmployee{
privateinthours;
privateintbahour=35;
privateintsalary;
publicHourlyEmployee(Stringname,intmonth,inthours){
super(name,month);
=hours;
}
publicintgetHours(){
returnhours;
}
publicvoidtHours(inthours){
=hours;
}
publicintgetSalary(intmonth){
ints=th();
if(hours<160){
if(flag==s){
salary=bahour*hours+100;
}el
salary=bahour*hours;
}el{
if(flag==s){
salary=(int)(bahour*hours*1.5)+100;
}el
salary=(int)(bahour*hours*1.5);
}
returnsalary;
}
voidsays(){
n(""+"姓名:"+e()+""+"生日所在月:"
+th()+""+"所得薪酬:"+getSalary(month));
}
}
//SalesEmployee:Employee的子类,销售人员,工资由月销售额和提成率决定。属性:月
销售额、提成率(sales<60000
//bonus=0.1,sales>=60000bonus=0.125)
classSalesEmployeeextendsEmployee{
privateintsales;
privatedoublebonus=0.1;
privateintsalary;
publicSalesEmployee(Stringname,intmonth,intsales){
super(name,month);
=sales;
}
publicintgetSales(){
returnsales;
}
publicvoidtSales(intsales){
=sales;
}
publicintgetSalary(intmonth){
ints=th();
if(sales<60000){
if(s==flag){
salary=(int)(sales*bonus)+100;
}el
salary=(int)(sales*bonus);
}el{
if(s==flag){
salary=(int)(sales*bonus*1.25)+100;
}el
salary=(int)(sales*bonus*1.25);
}
returnsalary;
}
voidsays(){
n(""+"姓名:"+e()+""+"生日所在月:"
+th()+""+"所得薪酬:"+getSalary(month));
}
}
//BaPlusSalesEmployee:SalesEmployee的子类,有固定底薪的销售人员,工资由底薪加上
销售提成部分。属性:底薪。
classBaPlusSalesEmployeeextendsEmployee{
privateintsales;
privateintba=3000;
privatedoublebonus=0.75;
privateintsalary;
publicBaPlusSalesEmployee(Stringname,intmonth,intsales){
super(name,month);
=sales;
}
publicintgetSales(){
returnsales;
}
publicvoidtSales(intsales){
=sales;
}
publicintgetSalary(intmonth){
ints=th();
if(sales<60000){
if(s==flag){
salary=(int)(sales*bonus)+ba+100;
}el
salary=(int)(sales*bonus)+ba;
}el{
if(s==flag){
salary=(int)(sales*bonus*1.25)+ba+100;
}el
salary=(int)(sales*bonus*1.25)+ba;
}
returnsalary;
}
voidsays(){
n(""+"姓名:"+e()+""+"生日所在月:"
+th()+""+"所得薪酬:"+getSalary(month));
}
}
//测试类
publicclassTest{
publicstaticvoidmain(String[]args){
Employeee=newEmployee("",0);
SalaryEmployee=newSalaryEmployee("基本工:张三",8);
HourlyEmployeehe=newHourlyEmployee("小时工:李四",11,190);
SalesEmployeesa=newSalesEmployee("销售额工:王二",3,79999);
BaPlusSalesEmployeebp=newBaPlusSalesEmployee("基本销售额工:于五
",7,5000);
();
();
();
();
();
}
}
本文发布于:2022-12-27 21:33:18,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/90/42761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |