Answered step by step
Verified Expert Solution
Link Copied!

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 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

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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago