TestSubclassEmployee.java
public class TestSubclassEmployee extends TestClassPerson{
/*定义成员变量*/
private String personName;//姓名
private int personAge;//年龄
private String personSex;//性别
private String workPlace;//工作单位
private String phoneNum;//电话号码
public void setPersonWorkplace(String work){
workPlace = work;
}
public void setPersonPhonenum(String pnum){
phoneNum = pnum;
}
public String getPersonWorkplace(){
return workPlace;
}
public String getPersonPhonenum(){
return phoneNum;
}
public static void main(String args[]){
TestSubclassEmployee person = new TestSubclassEmployee();
person.setPersonVar("王义",25,"男");
person.setPersonWorkplace("北京");
person.setPersonPhonenum("12345678");
String outName = person.getPersonName();
int outAge = person.getPersonAge();
String outSex = person.getPersonSex();
String outWorkplace = person.getPersonWorkplace();
String outPhonenum = person.getPersonPhonenum();/**/
/*定义成员变量*/
String personWorkplace;//工作地点
/*定义构造函数TestSuper(String name, int age, String sex, String work)*/
public TestSuper(String name, int age, String sex, String work){
super(name,age,sex);
personWorkplace = work;
System.out.println("姓名:"+ super.personName+",年龄:"+ super.personAge+",性别:"+ super.personSex+",工作地点:"+ personWorkplace);
}
public static void main(String args[]){
/*调用构造函数生成对象person*/
TestSuper person = new TestSuper("李玲",20,"女","北京");
}
}