1)Person类中的属性有:姓名name(String类型),地址address(String类型),
电话号码telphone(String类型)和电子邮件地址email(String类型);
(2)Employee类中的属性有:办公室office(String类型),工资wage(double
类型),受雇日期hiredate(String类型);
(3)Faculty类中的属性有:学位degree(String类型),级别level(String类型);
(4)Staff类中的属性有:职务称号duty(String类型)。
package zuoye;
public class Person {
//属性
public String name;//姓名
public String address;//地址
public String telphone;//电话
public String email;//邮箱
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getTelphone() {
return telphone;
}
public void setTelphone(String telphone) {
this.telphone = telphone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
package zuoye;
public class Employee extends Person{
public String office;//办公室
public double wage;//工资
public String hiredate;//受雇日期
public String getOffice() {
return office;
}
public void setOffice(String office) {
this.office = office;
}
public double getWage() {
return wage;
}
public void setWage(double wage) {
this.wage = wage;
}
public String getHiredate() {
return hiredate;
}
public void setHiredate(String hiredate) {
this.hiredate = hiredate;
}
}
package zuoye;
public class Faculty extends Employee {
public String degree;//学位
public String level;//级别
public String getDegree() {
return degree;
}
public void setDegree(String degree) {
this.degree = degree;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
}
package zuoye;
public class Staff extends Employee{
public String duty;
public String getDuty() {
return duty;
}
public void setDuty(String duty) {
this.duty = duty;
}
}
package zuoye;
public class Ceshi_person {
public static void main(String[] args) {
//测试
Person p=new Person();
p.setName("张三");
p.setAddress("x省x市x区123号");
p.setEmail("510652434@qq,com");
p.setTelphone("189xxxx6492");
System.out.println("姓名是:"+p.getName()+"地址是:"+p.getAddress()+"电话:"+p.getTelphone()+"邮箱:"+p.getEmail());
Employee e=new Employee();
e.setOffice("A座407");
e.setWage(5000.0);
e.setHiredate("16.08.16");
System.out.println("信息是:姓名是:"+p.getName()+"地址是:"+p.getAddress()+"电话:"+p.getTelphone()+"邮箱:"+p.getEmail()+"办公室:"+e.getOffice());
}
}