各个子类中拥有一些构造函数,它们的本体几乎完全一致
public class Manager extends Employee {public Manager(String name, String id, int grade) {this.name = name;this.id = id;this.grade = grade;}
}
重构:在超类中新建一个构造函数,并在子类构造函数中调用它
public Manager(String name, String id, int grade) {super(name, id);this.grade = grade;}