public class Test3 {
public static void main(String[] args) {
Staff s = new Staff("张三","123",5000);
System.out.println("员工, "+s.getName()+", "+s.getNumber()+", "+s.getPay()+", ");
Manager m = new Manager("李四","1",8000,2000);
System.out.println("经理, "+m.getName()+", "+m.getNumber()+", "+m.getPay()+", "+m.getBonus());
}
}
class Staff{
private String name;
private String number;
private int pay;
public Staff() {
super();
// TODO Auto-generated constructor stub
}
public Staff(String name, String number, int pay) {
super();
this.name = name;
this.number = number;
this.pay = pay;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public int getPay() {
return pay;
}
public void setPay(int pay) {
this.pay = pay;
}
}
class Manager extends Staff{
private int bonus;
public Manager() {
super();
}
public Manager(String name, String number, int pay, int bonus) {
super(name,number,pay,bonus);//报错The constructor Staff(String, String, int, int) is undefined
this.bonus = bonus;
}
public int getBonus() {
return bonus;
}
public void setBonus(int bonus) {
this.bonus = bonus;
}
}
小弟调不好啊 |
|