Answered step by step
Verified Expert Solution
Question
1 Approved Answer
. . . = Official Site of the C . . Twitch KKKKKKKK Movies The code for a class Ball has been started below. The
Official Site of the
Twitch
KKKKKKKK
Movies
The code for a class Ball has been started below.
The following links give specifications of three further methods that you should add to the code already given.
a equals: publicboolean equalsobject obj
Overrides: equals in class object
Parameters: obj object to compare with this object for equality
Returns: true if obj is a ballor subclass of whose diameter and x position are the same as this object, otherwise return false
b compareTo: public int compareTo ball bb
Specified by: compareTo in interface comparable
Parameters: bb a ball object to compare with this object
Returns: an integer greater than o if this ball has a greater diameter than the given ball, o if this ball has the same diameter as the given ball, an integer less than o if this ball has a smaller diameter than the given ball
c hashCode: public int hashcode
Overrides: hashCode in class object
Returns: an integer hash of the diameter and xPosition in that order using the objects.hash
Make any other alterations to the sa class required to implement the above methods.
Answer: penalty regime:
Reset answer
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