我帮你写,你采纳我
public abstract class Staff {
private String name;
private int age;
private String position;
@Override
public String toString() {
return position + "---" + "姓名:" + name + "," + "年龄:" + age + "," + "职业:" + position;
}
public Staff(String name, int age, String position) {
super();
this.name = name;
this.age = age;
this.position = position;
}
}
public class Test2 extends Staff{
public Test2(String name, int age, String position) {
super(name, age, position);
}
public static void main(String[] args) {
Test2 t = new Test2("李乐乐" , 20 , "干部");
System.out.println(t.toString());
Test2 t2 = new Test2("王小六" , 30 , "工人");
System.out.println(t2.toString());
}
}