public class Employee {
private String name;
private int num;
private int mone;
private String work;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getMone() {
return mone;
}
public void setMone(int mone) {
this.mone = mone;
}
public String getWork() {
return work;
}
public void setWork(String work) {
this.work = work;
}
public Employee() {}
public Employee(String name, int num, int mone, String work) {
this.name = name;
this.num = num;
this.mone = mone;
this.work = work;
}
@Override
public String toString() {
return "姓名:" + name + ", 工号:" + num + ", 薪水:" + mone + ", 工作内容:" + work;
}
}
public class Manager extends Employee{
private int bonus;
public int getBonus() {
return bonus;
}
public void setBonus(int bonus) {
this.bonus = bonus;
}
public Manager() {}
public Manager(String name, int num, int mone, String work, int bonus) {
super(name, num, mone, work);
this.bonus = bonus;
}
@Override
public String toString() {
return super.toString()+", 奖金:"+bonus;
}
}
public class Programmer extends Employee{
public Programmer(String name, int num, int mone, String work) {
super(name, num, mone, work);
}
public Programmer() {}
}
public class Test {
public static void main(String[] args) {
Programmer p = new Programmer("程序员", 002, 6000, "编写程序");
Manager m = new Manager("经理", 001, 8000, "看程序员编写程序", 2000);
System.out.println(p.toString());
System.out.println(m.toString());
}
}