CISP401系列员工.java,是我工资单应用程序的一部分。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CISP401系列员工.java,是我工资单应用程序的一部分。相关的知识,希望对你有一定的参考价值。
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(); } 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 ( return grossPay() .times (TAX_RATE); } return grossPay() .minus (taxAmount()); } public MyString formattedName() { return new MyString("" + emp.last + ", " + emp.first); } return emp.toString(); } // ) }
以上是关于CISP401系列员工.java,是我工资单应用程序的一部分。的主要内容,如果未能解决你的问题,请参考以下文章