Question: LANGUAGE: JAVA Problem description: A clock has the following components of time: hour, minute, and second. In a civilian time, the hour range of values
LANGUAGE: JAVA 

Problem description: A clock has the following components of time: hour, minute, and second. In a civilian time, the hour range of values are from 1 to 12, minute and second range of values are within 0 to 59. These values will differ if we take the military time. Adding values to these time elements will have the effect of cycling to the lowest value upon surpassing the highest value in the range. Such that if the value of hour is 12 and 1 is added to it, the resultant value will be equal to 1. As for the minute, if its current value is 59 and 1 is added, its result will revert the value of minute to 0 but a side effect of which is to add 1 to the hour. The second's value will be similar to the minute where if its current value is 59 and 1 is added to it, the second will become 0 but 1 will be added to the minute. In presenting the time, this format will be followed "hh:mm:ss". Hence if the values of hour, minute, and second are 9, 20, and 3, respectively, then the format will be "09:20:03". An alarm clock is a "special" clock in that other than having all of the elements of a regular clock, it will have a separate set of time elements for the alarm time. Requirements: Create the Clock class such that all the time elements will be accessed internally (within the class only) - name these variables as hour, minute, and second. Provide the necessary getter/setter methods (must be defined with the most open accessibility) for the time elements. Assume that the values to be provided as parameters for the setter methods will be valid. Provide the following additional operations/methods for this class (all methods must be defined with the most open accessibility): addHour() - this method increases the value of hour by 1 addMinute() - this method increases the value of minute by 1 addSecond() - this method increases the value of second by 1 addTime(int hour, int minute, int second) - increases the time element values with the values of the provided parameters setTime(int hour, int minute, int second) - sets the time element values with the values of the provided parameters. Just assume that the values will be valid. toString() - this method returns the formatted value of the clock's time (hh:mm:ss") Create the following constructors for this class. There should be no other constructors for the class except for the ones defined below: A constructor that accepts a single integer value which will be used to set the value of hour. Just assume that the value is a valid. A constructor that accepts a two integer values. The first value will be used to set the value of hour. The second value will be used to set the value of minute. Just assume that the values are valid. A constructor that accepts three integer values. The first value will be used to set the value of hour. The second value will be used to set the value of minute. And the third value will be used to set the second. Just assume that the values are valid. Create AlarmClock as a subclass of Clock. Provide the added state/attributes for this class based on the problem description. These variables are to be used/accessed within the class only. Provide the necessary getter/setter methods (defined with the most open accessibility) for these added attributes. Overload the following methods for this class: addHour(int incValue) - this method increases the value of hour by the parameter's value addMinute(int incValue) - this method increases the value of minute by the parameter's value addSecond(int incValue) - this method increases the value of second by the parameter's value Additionally, you are to provide the following additional functionalities for the subclass: setAlarmTime(int hour, int minute, int second) - this method sets the alarm (time elements) with the provided parameters triggerAlarm() - this method returns true if the current time value is the same as that of the alarm time value and false if otherwise. Create the sole constructor for AlarmClock class. This should be the only constructor to be defined for the class: A constructor with no arguments and it will set all the time elements to their respective minimum values
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
