Answered step by step
Verified Expert Solution
Link Copied!

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 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".
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions

Question

1. Which is the most abundant gas presented in the atmosphere?

Answered: 1 week ago