第十一周作业
1.colaemployee and getsalary
package hhhhkj;
public class colaEmployee {
String name;
int month;
int x=2000;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public colaEmployee(String name, int month) {
super();
this.name = name;
this.month = month;
}
public colaEmployee(){
super();
}
public void getSalary(int month){
if(month==10)
x+=100;
}
}
public class hourlyEmployee extends colaEmployee {
private int hourlysalary;
private int hourlytime;
public hourlyEmployee() {
super();
}
public hourlyEmployee(String name, int month,int hourlytime,int hourlysalary) {
super(name, month);
this.hourlytime=hourlytime;
this.hourlysalary=hourlysalary;
}
public double getHourlysalary(int month) {
if (super.month == month) {
if (hourlytime > 160) {
return hourlysalary * 160 + hourlysalary * (hourlytime - 160) * 1.5 + 100;
} else {
return hourlysalary * hourlytime + 100;
}
} else {
if (hourlytime > 160) {
return hourlysalary * 160 + hourlysalary * (hourlytime - 160) * 1.5;
} else {
return hourlysalary * hourlytime;
}
}
}
}
package hellowhomework;
public class SalariedEmployee extends ColaEmployee{
int monthmoney;
public void gudingSalar(String name,int month,int birthday, int monthmoney) {
if(month==birthday) {
System.out.println(name+"工资为"+(monthmoney+100));
}else {
System.out.println(name+"工资为"+monthmoney);
}
}
}
package kjlkjklkj;
public class SalariedEmployee extends ColaEmployee{
int monthmoney;
public void gudingSalar(String name,int month,int birthday, int monthmoney) {
if(month==birthday) {
System.out.println(name+"工资为"+(monthmoney+100));
}else {
System.out.println(name+"工资为"+monthmoney);
}
}
}
测试类
package ww;
public class TestCompany {
public static void main(String[] args) {
Company C = new Company();
HourlyEmployee s= new HourlyEmployee();
s.method(s);
SalariedEmployee c = new SalariedEmployee();
C.method(c);
SalesEmployee l = new SalesEmployee();
C.method(l);
}
}

浙公网安备 33010602011771号