private?String?name;
private?Integer?age;
private?String?phone;
public?String?getMessage()?{
return?"People:?姓名:"+name+",年齡:"+age+",電話:"+phone;
}
public?String?getName()?{
return?name;
}
public?void?setName(String?name)?{
this.name?=?name;
}
public?Integer?getAge()?{
return?age;
}
public?void?setAge(Integer?age)?{
this.age?=?age;
}
public?String?getPhone()?{
return?phone;
}
public?void?setPhone(String?phone)?{
this.phone?=?phone;
}
}public?class?Student?extends?People{
private?Integer?id;
public?String?getMessage(Integer?id)?{
return?"Student:?姓名:"+super.getName()+",年齡:"+super.getAge()+",電話:"+super.getPhone()+",學號:"+id;
}
public?Integer?getId()?{
return?id;
}
public?void?setId(Integer?id)?{
this.id?=?id;
}
}public?class?S?{
public?static?void?main(String[]?args)?{
Student?student?=?new?Student();
student.setId(13);
student.setName("李三");
student.setAge(18);
student.setPhone("123-4567-8901");
System.out.println(student.getMessage(student.getId()));
}
}