Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions