Question: Write the Java class that corresponds to the UML class Diagram below. You must implement each method according to its description below the class diagram.
Write the Java class that corresponds to the UML class Diagram below. You must implement each method according to its description below the class diagram. > Clock() Simple default constructor that initializes fields to zero > clock (hours: int, mins:int, secs:int) Simple default constructor that initializes fields to the given parameter values Must check for invalid values like negative values and values of mins/secs being greater than or equal to 60. If an invalid value is found, pnnt out an error message. +addHours(amount:int) Adds the parameter amount to the number of hours field +addMins(amount:int) Adds the parameter amount to the number of minutes field You must detect when the number of minutes meets or exceeds 60. If it does, you must add 1 to the number of hours and subtract 60 from the number of minutes +addSecs(amount:int) Adds the parameter amount to the number of seconds field You must detect when the number of seconds meets or exceeds 60. If it does, you must add 1 to the number of minutes (which could cause the number of minutes to now be at or above 60, which must be handled if this happens) and subtract 60 from the number of seconds +print() Use the printf function to print the number of hours, number of minutes and number of seconds Must place a colon in between the value of each field. Write your code on the next page. Use the following page if more room is needed. Don't forget the bonus at the end of the last page
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
