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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!