Question: Write the FULL j = Java code for the following Dumbbell class. This class represents dumbbells, a concrete class that extends from FreeWeight. It will

Write the FULL j=Java code for the following Dumbbell class.
This class represents dumbbells, a concrete class that extends from FreeWeight. It will have:
The following instance variables: gripType (String).
3-arg constructor that takes the freeWeightID, weight, and gripType. It will set the
category to 2.
A compareTo method to allow comparing the class to other FreeWeight (not just
Dumbbell instances). This is an override to FreeWeight's compareTo, which further
orders elements that the previous definition established as equal. The ordering of
FreeWeight established by this class is the following:
Order first by category, in ascending order
If it has the same category, the instance is guaranteed to be a Dumbbell,
and you can downcast the parameter for the comparisons that cannot
be done against a general FreeWeight
Order second by weight, in ascending order
Order third by gripType, in ascending lexicographical order
Order fourth by freeWeightID, in ascending lexicographical order.
Tip: using the super implementation of compareTo to handle only cases that
have a return value of 0 in the super implementation is recommended
A toString method with the following format:
"[freeWeightID]: [weight] Ib. dumbbell with [gripType] grip" (without square
brackets)
You must use the super implementation of the toString method.
A getter for the instance variable.

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!