public class Abstract {
public static void main(String[] args) {
Employee employee = new Employee("张三", 100);
employee.job();
}
}
abstract class Company {
private String name;
private double money;
public Company(String name, double money) {
this.name = name;
this.money = money;
}
public abstract void job();
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setMoney(double money) {
this.money = money;
}
public double getMonry() {
return money;
}
}
class Employee extends Company {
public Employee(String name, double money) {
super(name, money);
}
public void job() {
System.out.println(super.getName() + super.getMonry() + "敲代码");
}
}
class Manager extends Company {
private double bonus;
public Manager(String name, double money, double bonus) {
super(name, money);
this.bonus = bonus;
}
public void job() {
System.out.println(super.getName() + super.getMonry() + " "
+ this.bonus + "指挥敲代码");
}
}
class Clear extends Company {
public Clear(String name, double money) {
super(name, money);
}
public void job() {
System.out.println(super.getName() + super.getMonry() + "清理垃圾");
}
}
在new子类的时候将 参数 传入子类的构造函数里,再通过super() 传给父类构造函数,然后下面name和money是怎么在父类里面传递的,是怎么通过子类的覆盖父类的方法job() {super.getName() + super.getMonry()}最后打印输出的?
父类的构造方法里的this.name和setName里的this.name,各自的作用是什么,到底谁给谁啊?