package chen;
public class Person {
//name,address,phone number,email address;
private String name;
private String address;
private String phone_number;
private String email_address;
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 getPhone_number() {
return phone_number;
}
public void setPhone_number(String phoneNumber) {
phone_number = phoneNumber;
}
public String getEmail_address() {
return email_address;
}
public void setEmail_address(String emailAddress) {
email_address = emailAddress;
}
Person()
{
System.out.println("PERSON");
}
}
package chen;
public class Employee extends Person {
//Employee类的属性包括office, date-hired,office hour和rank(工作时间和工作等级)
private String office;
private String date_hired;
private int office_hour;
private int rank;
public String getOffice() {
return office;
}
public void setOffice(String office) {
this.office = office;
}
public String getDate_hired() {
return date_hired;
}
public void setDate_hired(String dateHired) {
date_hired = dateHired;
}
public int getOffice_hour() {
return office_hour;
}
public void setOffice_hour(int officeHour) {
office_hour = officeHour;
}
public int getRank() {
return rank;
}
public void setRank(int rank) {
this.rank = rank;
}
public Employee(int office_hour,int rank) {
System.out.println("EMPLOYEE");
this.office_hour=office_hour;
this.rank=rank;
}
public void computeSalary()
{
System.out.println("本月工资为:"+(office_hour*rank));
}
}
package chen;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
//在生成Employee对象时自动初始化office hour和rank
Employee e=new Employee(10,10);
e.computeSalary();
}
}