Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose that a class ClockTime has been defined for storing information about times of day. The class code is linked under the problem title in
Suppose that a class ClockTime has been defined for storing information about times of day. The class code is linked under the
problem title in "Related Links". Each ClockTime object keeps track of hours, minutes, and a String to indicate am or pm The class
includes the following members:
Your task is to modify the class to be Comparable by adding an appropriate compareTo method. The earliest time is : am and the
latest time is : In between the time increases as it would in a standard clock. Keep in mind that : am is followed by :
am that : is followed by : and that : is followed by :
Assume that the values passed to your constructor are legal. In particular, hours will be between and inclusive, minutes will be
between and inclusive, and the parameter will be either the string or the string These values should be returned
by the various get methods.
The tostring method returns a string composed of the hours followed by a colon followed by the minutes digits followed by a
space followed by the ampm String. For example, given these declarations:
ClockTime time new ClockTimeam;
ClockTime time new ClockTimepm;
timetoString would return : am and time toString should return : pm
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