Question: 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 12:00 am and the
latest time is 11:59pm. In between the time increases as it would in a standard clock. Keep in mind that 12:59 am is followed by 1:00
am, that 11:59am is followed by 12:00pm, and that 12:59pm is followed by 1:00pm.
Assume that the values passed to your constructor are legal. In particular, hours will be between 1 and 12 inclusive, minutes will be
between 0 and 59 inclusive, and the ampm parameter will be either the string "am" or the string "pm". 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 (2 digits) followed by a
space followed by the am/pm String. For example, given these declarations:
ClockTime time1= new ClockTime(8,31,"am");
ClockTime time2= new ClockTime(12,7,"pm");
time1.toString() would return "8:31 am" and time2. toString() should return "12:07 pm".
 Suppose that a class ClockTime has been defined for storing information

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!