Created
January 14, 2012 02:34
-
-
Save coderunner/1610005 to your computer and use it in GitHub Desktop.
Employee Class - Object Way
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 String name; | |
| private int age; | |
| private int salary; | |
| private float targetBonus; | |
| public Employee() | |
| {} | |
| 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; | |
| } | |
| public void setName(String name) { | |
| this.name = name; | |
| } | |
| //...then other getters and setters |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment