Write an equals method for the StepsFitnessTracker class thattests whether the one object is equal to another
Question:
Write an equals method for the StepsFitnessTracker class thattests whether the one object is equal to another object that ispassed as an argument (Object otherObject). The Object superclassprovides an equals method that tests if two object references areequal. Your new equals method should override the Object equalsmethod, and should test the following: ? Return true if the current(this) object, and otherObject are identical references (hint: youcan use the == operator for this). ? Returns false if otherObjectis null. ? Returns false if the current (this) object andotherObject have different classes (hint: you can use thegetClass() method provided by the Object superclass, see the Java 8API documentation for details). ? Casts otherObject to aStepsFitnessTracker, and tests for equality of each instancevariable1 , if the instance variables are the same the methodshould return true
Now write an equals method for the DistanceFitnessTracker andHeartRateFitnessTracker classes that: ? Use the superclass equalsmethod, and return false if this method fails. ? Casts theparameter to either HeartRateFitnessTracker orDistanceFitnessTracker. ? Tests for equality of the subclassinstance fields. Please, use JUnit testing and write a test classnamed TestFTEquals to test that these new equals methods workproperly. For inspiration, you can have a look at the test classesprovided (TestFitnessTracker, TestDistanceFitnessTracker,TestStepsFitnessTracker, and TestHeartRateFitnessTracker) as theyare already providing you some basic tests about how to test forequality of objects.
I wrote the equal methods for the classes they need but I amhaving trouble solve the TESTFTEQUAL Junit test
I added all the code needed please provide it has soonas possible please please
Starting Out With Java From Control Structures Through Data Structures
ISBN: 9780133957051
6th Edition
Authors: Tony Gaddis