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.

Revisions

  1. coderunner revised this gist Jan 14, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions employee.java
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    public class ImmutableEmployee {
    public class Employee {

    private final String name;
    private final int age;
    private final int salary;
    private final float targetBonus;

    public ImmutableEmployee(String name, int age, int salary, float targetBonus) {
    public Employee(String name, int age, int salary, float targetBonus) {
    this.name = name;
    this.age = age;
    this.salary = salary;
    @@ -28,4 +28,4 @@ public String getName() {
    return name;
    }

    //then other getters...
    //...then other getters
  2. coderunner revised this gist Jan 14, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions employee.java
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    public class ImmutableEmployee {

    private final String name;
    private final int age;
    private final int salary;
  3. coderunner renamed this gist Jan 14, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. coderunner created this gist Jan 14, 2012.
    30 changes: 30 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    public class ImmutableEmployee {
    private final String name;
    private final int age;
    private final int salary;
    private final float targetBonus;

    public ImmutableEmployee(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...