Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Class;
- public class Employee {
- /* properties */
- protected String name;
- protected int uniqueID;
- protected float salary;
- protected final static float SALARY_MIN = .0f;
- protected static int uid_count = 1000;
- /* set, get methods */
- public void setName(String name) {
- this.name = name;
- }
- public String getName() { return this.name; }
- public void setUniqueID(int uniqueID) {
- if (uniqueID < 1000) { uniqueID = uid_count; }
- this.uniqueID = uniqueID;
- }
- public int getUniqueID() { return this.uniqueID; }
- public void setSalary(float salary) {
- this.salary = salary;
- }
- public float getSalary() { return this.salary; }
- /* constructors */
- public Employee(String name, int uniqueID, float salary) {
- this.setName(name);
- this.setUniqueID(uniqueID);
- this.setSalary(salary);
- uidCountInc();
- }
- public Employee(String name, int uniqueID) {
- this(name, uniqueID, SALARY_MIN);
- }
- public Employee(String name) {
- this(name, uid_count, SALARY_MIN);
- }
- /* methods */
- public String toString() {
- String str = String.format("(%s@%h)\tname=%s\tuid=%d\tsalary=%.2f",
- this.getClass().getName(), this, name, uniqueID, salary);
- return str;
- }
- public static void uidCountInc() {
- uid_count += 1;
- }
- public float calcBonus() {
- return this.salary; //no bonus
- }
- public boolean updateSalary(float salary) {
- float oldSalary = this.salary;
- setSalary(salary);
- return (oldSalary != this.salary)?true:false;
- }
- }
Add Comment
Please, Sign In to add comment