Question: In java add an equals method to the Project class so that two Project objects are equal if both of their switches are in the
In java add an equals method to the Project class so that two Project objects are equal if both of their switches are in the same states. Also, add a hashcode method to this class so that if two Project objects are considered equal, then they produce the same hashcode.
public class Project
{
public static boolean switchA;
public static boolean switchB;
public Project()
{
this.switchA = true;
this.switchB = false;
}
public void flip1()
{
switchA = !switchA;
}
public void flip2()
{
switchB = !switchB;
}
public boolean isLightOn()
{
return switchA == switchB;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
