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());
}
}

