Skip to content

Instantly share code, notes, and snippets.

@coderunner
Created January 14, 2012 02:44
Show Gist options
  • Select an option

  • Save coderunner/1610028 to your computer and use it in GitHub Desktop.

Select an option

Save coderunner/1610028 to your computer and use it in GitHub Desktop.
Employee Class - Immutable
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