Created
March 18, 2018 02:33
-
-
Save BalicantaYao/dea8f28933895ea73bedc517aca12f4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework.week7; | |
public class Employee { | |
private String firstName; | |
private String lastName; | |
public Employee(String firstName, String lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
//getter, setter | |
public String getFirstName() { | |
return firstName; | |
} | |
public void setFirstName(String firstName) { | |
this.firstName = firstName; | |
} | |
public String getLastName() { | |
//lastName; | |
return lastName; | |
} | |
public void setLastName(String lastName) { | |
this.lastName = lastName; | |
} | |
// Employee: David - Wang | |
public String getFullName() { | |
return " Employee:" + this.firstName + " - " +this.lastName; | |
} | |
public static void main(String[] args) { | |
Employee ted = new Employee("Ted", "Chen"); | |
System.out.println(ted.getFullName()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework.week7; | |
public class FullTimeEmployee extends Employee { | |
private int salary; | |
public FullTimeEmployee(String firstName, String lastName) { | |
super(firstName, lastName); | |
// 預設薪水 - 三萬五 | |
this.salary = 35000; | |
} | |
public int getSalary() { | |
return salary; | |
} | |
public void setSalary(int salary) { | |
this.salary = salary; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework.week7; | |
public class Manager extends Employee { | |
// 月薪 | |
private int salary; | |
// 管理加給 | |
private int manageFee; | |
public Manager(String firstName, String lastName) { | |
super(firstName, lastName); | |
this.salary = 40000; | |
this.manageFee = 5000; | |
} | |
public int getSalary() { | |
return salary; | |
} | |
public void setSalary(int salary) { | |
this.salary = salary; | |
} | |
public int getManageFee() { | |
return manageFee; | |
} | |
public void setManageFee(int manageFee) { | |
this.manageFee = manageFee; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework.week7; | |
public class PartTimeEmployee extends Employee { | |
public PartTimeEmployee(String firstName, String lastName) { | |
super(firstName, lastName); | |
} | |
public String getFullName() { | |
//return super.getFullName(); | |
return "PartTimeEmployee:" + this.getFirstName() + " - " + this.getLastName(); | |
} | |
public static void main (String args[]) { | |
PartTimeEmployee yao = new PartTimeEmployee("Yao", "Yao"); | |
System.out.println(yao.getFullName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment