Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 jJava 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
arg constructor that takes the freeWeightID, weight, and gripType. It will set the
category to
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started