I have the emplyee class and i need to implement a method in this class that checks to see if two employees are equal meeaning they have the same ID and name attributes. Can someone please explain how i can use override and complete this method so the method can perform the equality check while using object as an input to the method. Also what would be a good test method for this.
package employees;
// -------------------------------------------------------------------------
/**
* Represents an average employee working 40 hours per week.
*
* @author Megan Rigsbee (mrigsbee), JW Lee (jiayiw6)
* @version 2019.09.01
*/
public class Employee {
// ~ Fields ................................................................
private String name;
private int employeeId;
private double hourlyRate;
// ~ Constructor ...........................................................
/**
* New Employee object.
*
* @param name
* Name of Employee
* @param employeeId
* Employee ID of Employee
* @param hourlyRate
* Pay rate of Employee (per hour).
*/
public Employee(String name, int employeeId, double hourlyRate) {
this.name = name;
this.employeeId = employeeId;
this.hourlyRate = hourlyRate;
}
// ~ Methods ...............................................................
// ----------------------------------------------------------
/**
* Gets the employee's name.
*
* @return the employee's name
*/
public String getName() {
return name;
}
// ----------------------------------------------------------
/**
* Gets the employee's employee identifier.
*
* @return the employee's employee identifier
*/
public int getEmployeeId() {
return employeeId;
}
// ----------------------------------------------------------
/**
* Gets the pay rate (per hour).
*
* @return the pay rate
*/
public double getHourlyRate() {
return hourlyRate;
}
// ----------------------------------------------------------
/**
* Amount paid to the employee for an average 40 hour work week.
*
* @return weekly Weekly pay for employee
*/
public double weeklyPay() {
return hourlyRate * 40;
}
@Override
public boolean equals(Object obj)
{
return false;
//Implementation goes here.
}
}