Question: Coding language is Java. Create a program called CustomClock. CustomClock should contain a default constructor (setting the time to 0:00:00, daylight savings time is off)

Coding language is Java.

Create a program called CustomClock. CustomClock should contain a default constructor (setting the time to 0:00:00, daylight savings time is off) and a constructor with arguments for hours, minutes, seconds and daylight_savings

CustomClock should have the following attributes:

Hours (int) (Range can only be 0 to 23)

Minutes (int) (Range can only be 0 to 59)

Seconds (int) (Range can only be 0 to 59)

daylight_savings (boolean)

And the following methods (Denoted as name: return type - description):

getHours(): int Returns the current hour.

getMinutes(): int Returns the current minute.

getSeconds(): int Returns the current second.

setTime(int newHours, int newMinutes, int newSeconds): void Sets the time to the given hour, minute, and second. If any of the presented values are out of acceptable range (see above), set the accompanying value to 0 instead.

tick(): void Advance time by one second. If seconds reaches 60, set seconds to 0 and increment minutes by 1. If minutes hits 60, set minutes to 0 and increment hours by 1. If hours reaches 24, set hours to 0.

toggleDLS(): void Toggle daylight_savings, updating time as needed. If daylight_savings is changed from false to true, increment hours by 1. If daylight_savings is changed from true to false, decrement hours by 1.

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!