Revision: 34115
Updated Code
at November 19, 2010 20:13 by trusktr
Updated Code
import java.util.*; public abstract class Employee implements Comparable<Employee> { // Data Objects ( private EmployeeData emp; private static final double TAX_RATE = 0.15; // ) // Constructors ( public Employee() { emp = new EmployeeData(); } public Employee(String f, String l) { emp = new EmployeeData(f, l); } public Employee(MyString f, MyString l) { emp = new EmployeeData(f, l); } public Employee(EmployeeData d) { emp = new EmployeeData(d); } public Employee(Employee e) { emp = new EmployeeData(e.emp); } // ) // Accessors ( public EmployeeData info() { return new EmployeeData(emp); } private EmployeeData get() { // private for use by compareTo return emp; } public int compareTo(Employee other) { // This is a overloaded method from the Comparable class for comparing two object (in my case Employee objects) in alphabetical order (which is the default behavior with compareTO when using strings). return (""+ emp.last + emp.first).compareTo(""+ other.get().last + other.get().first); // compareTo with String inputs automatically puts them in alphabetical order. } // ) // Mutators ( public abstract Number grossPay(); public Number taxAmount() { return grossPay() .times (TAX_RATE); } public Number netPay() { return grossPay() .minus (taxAmount()); } public MyString formattedName() { return new MyString("" + emp.last + ", " + emp.first); } public String toString() { return emp.toString(); } // ) }
Revision: 34114
Updated Code
at November 19, 2010 20:12 by trusktr
Updated Code
import java.util.*; public abstract class Employee implements Comparable<Employee> { // Data Objects ( private EmployeeData emp; private static final double TAX_RATE = 0.15; // ) // Constructors ( public Employee() { emp = new EmployeeData(); } public Employee(String f, String l, double hrs, double pr, double pcs, double pcr, double sal) { emp = new EmployeeData(f, l, hrs, pr, pcs, pcr, sal); } public Employee(MyString f, MyString l, Number hrs, Number pr, Number pcs, Number pcr, Number sal) { emp = new EmployeeData(f, l, hrs, pr, pcs, pcr, sal); } public Employee(EmployeeData d) { emp = new EmployeeData(d); } public Employee(Employee e) { emp = new EmployeeData(e.emp); } // ) // Accessors ( public EmployeeData info() { return new EmployeeData(emp); } private EmployeeData get() { // private for use by compareTo return emp; } public int compareTo(Employee other) { // This is a overloaded method from the Comparable class for comparing two object (in my case Employee objects) in alphabetical order (which is the default behavior with compareTO when using strings). return (""+ emp.last + emp.first).compareTo(""+ other.get().last + other.get().first); // compareTo with String inputs automatically puts them in alphabetical order. } // ) // Mutators ( public abstract Number grossPay(); public Number taxAmount() { return grossPay() .times (TAX_RATE); } public Number netPay() { return grossPay() .minus (taxAmount()); } public MyString formattedName() { return new MyString("" + emp.last + ", " + emp.first); } public String toString() { return emp.toString(); } // ) }
Revision: 34113
Updated Code
at October 17, 2010 15:23 by trusktr
Updated Code
import java.util.*; public class Employee implements Comparable<Employee> { // Data Objects ( private EmployeeData emp; private static final double OVERTIME_FACTOR = 1.5; private static final double TAX_RATE = 0.15; // ) // Constructors ( public Employee() { emp = new EmployeeData(); } public Employee(String f, String l, double pr, double hrs) { emp = new EmployeeData(f, l, pr, hrs); } public Employee(MyString f, MyString l, Number pr, Number hrs) { emp = new EmployeeData(f, l, pr, hrs); } public Employee(EmployeeData d) { emp = new EmployeeData(d); } public Employee(Employee e) { emp = new EmployeeData(e.emp); } // ) // Accessors ( public EmployeeData info() { return new EmployeeData(emp); } private EmployeeData get() { return emp; } public int compareTo(Employee other) { // This is a overloaded method from the Comparable class for comparing two object (in my case Employee objects) in alphabetical order (which is the default behavior with compareTO when using strings). return (""+ emp.last + emp.first).compareTo(""+ other.get().last + other.get().first); // compareTo with String inputs automatically puts them in alphabetical order. } // ) // Mutators ( public Number payRate() { return new Number(emp.payrate); } public Number hours() { return new Number(emp.hours); } public Number regHours() { Number regHrs = new Number(); if(emp.hours.value() <= 40){ regHrs.set_value(emp.hours); } else if(emp.hours.value() > 40){ regHrs.set_value(40); } return regHrs; } public Number ovrHours() { Number ovrHrs = new Number(); if(emp.hours.value() <= 40){ ovrHrs.set_value(0); } else if(emp.hours.value() > 40){ ovrHrs = emp.hours .minus (40); } return ovrHrs; } public Number grossPay() { return regHours() .times (emp.payrate) .plus ( ovrHours() .times (OVERTIME_FACTOR) .times (emp.payrate) ); } public Number taxAmount() { return grossPay() .times (TAX_RATE); } public Number netPay() { return grossPay() .minus (taxAmount()); } public MyString formattedName() { return new MyString("" + emp.last + ", " + emp.first); } public String toString() { return emp.toString(); } // ) }
Revision: 34112
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 17, 2010 12:02 by trusktr
Initial Code
import java.util.*; public class Employee implements Comparable<Employee> { // Data Objects ( private EmployeeData emp; private static final double OVERTIME_FACTOR = 1.5; private static final double TAX_RATE = 0.15; // ) // Constructors ( public Employee() { emp = new EmployeeData(); } public Employee(String f, String l, double pr, double hrs) { emp = new EmployeeData(f, l, pr, hrs); } public Employee(MyString f, MyString l, Number pr, Number hrs) { emp = new EmployeeData(f, l, pr, hrs); } public Employee(EmployeeData d) { emp = new EmployeeData(d); } public Employee(Employee e) { emp = new EmployeeData(e.emp); } // ) // Accessors ( public EmployeeData info() { return new EmployeeData(emp); } private EmployeeData get() { return emp; } public int compareTo(Employee other) { // This is a overloaded method from the Comparable class for comparing two object (in my case Employee objects) in alphabetical order (which is the default behavior with compareTO when using strings). return (""+ emp.last + emp.first).compareTo(""+ other.get().last + other.get().first); // compareTo with String inputs automatically puts them in alphabetical order. } // ) // Mutators ( public Number payRate() { return new Number(emp.payrate); } public Number hours() { return new Number(emp.hours); } public Number regHours() { Number regHrs = new Number(); if(emp.hours.value() <= 40){ regHrs.set_value(emp.hours); } else if(emp.hours.value() > 40){ regHrs.set_value(40); } return regHrs; } public Number ovrHours() { Number ovrHrs = new Number(); if(emp.hours.value() <= 40){ ovrHrs.set_value(0); } else if(emp.hours.value() > 40){ ovrHrs = emp.hours .minus (40); } return ovrHrs; } public Number grossPay() { return regHours() .times (emp.payrate) .plus ( ovrHours() .times (OVERTIME_FACTOR) .times (emp.payrate) ); } public Number taxAmount() { return grossPay() .times (TAX_RATE); } public Number netPay() { return grossPay() .minus (taxAmount()); } public MyString formattedName() { return new MyString("" + emp.last + ", " + emp.first); } public String toString() { return emp.toString(); } // ) }
Initial URL
Initial Description
Initial Title
CISP401 Employee.java, part of my payroll app.
Initial Tags
java
Initial Language
Java