Created
January 14, 2012 02:44
-
-
Save coderunner/1610028 to your computer and use it in GitHub Desktop.
Employee Class - Immutable
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
| public class Employee { | |
| private final String name; | |
| private final int age; | |
| private final int salary; | |
| private final float targetBonus; | |
| public Employee(String name, int age, int salary, float targetBonus) { | |
| this.name = name; | |
| this.age = age; | |
| this.salary = salary; | |
| this.targetBonus = targetBonus; | |
| } | |
| public int computeBonus(float factor) { | |
| return Math.round(salary * factor * targetBonus); | |
| } | |
| public int getWeeklySalary() { | |
| return Math.round(salary / 52f); | |
| } | |
| public boolean isEligibleForBenefits() { | |
| return age > 50; | |
| } | |
| public String getName() { | |
| return name; | |
| } | |
| //...then other getters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment