admin 3周前 (11-06) 回复

ces

匿名网友 3周前 (11-06) 回复

您有一份文件待查收!即刻点击链接获取文件:https://cowtransfer.com/s/0ea90a15c76a4f 或进入 cowtransfer.com 获取,在首页输入取件码:530295(24小时内有效)

匿名网友 3周前 (11-06) 回复

您有一份文件待查收!即刻点击链接获取文件:https://cowtransfer.com/s/a7d3b45941e84f 或进入 cowtransfer.com 获取,在首页输入取件码:224791(24小时内有效)

匿名网友 3周前 (11-06) 回复

package sy2_137;

public class TextEmployee137 {

public static void main(String[] args) {
// TODO Auto-generated method stub
Employee137 ref; //定义一个父类声明ref
ref = new Boss137 ("张三",1000); //父类引用指向子类对象
System.out.println(ref + ", weeklySalary:" + ref.earnings());
ref = new PieceWork137("李四",2,200);
System.out.println(ref + ", weeklySalary:" + ref.earnings());
ref = new HourlyWorker137("王五",13,40);
System.out.println(ref + ", weeklySalary:" + ref.earnings());

}

}

匿名网友 3周前 (11-06) 回复

package sy2_137;

public class PieceWork137 extends Employee137{


private int hour;
private double Piece;

public PieceWork137(String name, int hour, double piece) {
super(name);
this.hour = hour;
Piece = piece;
}

public int getHour() {
return hour;
}

public void setHour(int hour) {
this.hour = hour;
}

public double getPiece() {
return Piece;
}

public void setPiece(double piece) {
Piece = piece;
}

public double earnings(){
return hour*Piece;
}

public String toString(){
return "Boss: " + super.toString();

}



}

匿名网友 3周前 (11-06) 回复

package sy2_137;

public class HourlyWorker137 extends Employee137{

private int time;
private int money;
public HourlyWorker137(String name, int time, int money) {
super(name);
this.time = time;
this.money = money;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}

public double earnings(){
return time*money;
}

public String toString(){
return "Boss: " + super.toString();

}
}

匿名网友 3周前 (11-06) 回复

package sy2_137;

public class Employee137 {
private String name;//成员变量

public Employee137(String name) {//构造方法
this.name = name;
}

public String getName() {//获取name的方法
return name;
}
public void setName(String name) {//设置name的方法
this.name = name;
}
public String toString() {
return name;
}
public double earnings() {
return 0.0;

}
}

匿名网友 3周前 (11-06) 回复

package sy2_137;

public class Boss137 extends Employee137{

private double weeklySalary;

public Boss137(String name, double weeklySalary) {
super(name);
this.weeklySalary = weeklySalary;
}


public double getWeeklySalary() {
return weeklySalary;
}

public void setWeeklySalary(double weeklySalary) {
this.weeklySalary = weeklySalary;
}

public double earnings() {
return weeklySalary;
}
public String toString(){
return "Boss: " + super.toString();
}


}