我得到了下面的代码作为家庭作业。我被要求为员工对象实施比较器。compare 方法返回一个 int。但是,如果您比较它们,我在员工类中的所有方法都不会返回 int。谁能给我一些关于比较方法应该如何工作的指导?谢谢
import java.util.*;
import java.io.*;
public class EmployeeClient
{
//A Comparator for Employees
// Primary key : Employee category - Salaried > Weekly > Daily
// Secondary key : Employee gross pay
private static class EmployeeComparator implements Comparator
{
public int compare(Object one, Object two)
{
Employee uno = (Employee) one;
Employee dos = (Employee) two;
}
}
public abstract class Employee {
private String idNumber;
private double payRate;
//Accessor: Return the id number of employee
public String getidNumber()
{
return idNumber;
}
//Accessor: Return the payrate of the employee
public double getpayRate()
{
return payRate;
}
public String toString()
{
return getidNumber()+" "+getpayRate();
}
public abstract double grossPay();
}