Question: Problem. Write a mutable data type Clock. java that represents time on a 24-hour clock, such as 00:00, 13:30, or 23:59. Time is measured in

 Problem. Write a mutable data type Clock. java that represents time

Problem. Write a mutable data type Clock. java that represents time on a 24-hour clock, such as 00:00, 13:30, or 23:59. Time is measured in hours (0023) and minutes (00-59). Part I Implement the following API: Here is some more information about the required behavior: - Two-argument constructor. Throw an IllegalArgumentException if either integer argument is outside its prescribed bounds (hours between 0 and 23 , minutes between 0 and 59 ). - String representation. The format is the hours (2 digits), followed by a colon, followed by the minutes (2 digits). Two examples are 00:00 and 23:59. - Ordering. Times are ordered from 00:00 (earliest) to 23:59 (latest). - Tic. Add one minute to the current time. For example, one minute after 06:00 is 06:01; one minute after 23:59 is 00:00. - Test client. The main() method must not only call each instance method directly, but it must also help verify that each method works as prescribed (e.g., by printing results to standard output). Part II Add the following one-argument constructor to your data type. public Clock(String time) creates a clock whose initial time is specified as a string, using the format HH:MM The string argument is composed of two digits, followed by a colon, followed by two digits, such a "09: 45". Throw an IllegalArgumentException if either the string argument is not in this format or if it does not correspond to a valid time between 00:00 and 23:59. Hint. The function Integer.parseInt() ignores any leadings zeros. For example, Integer.parseInt("09") returns the integer 9

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!