Question: Clock.java - Write a class named Clock that contains the following variables, methods, and constructors: A. Private instance variables that store hours (0-23), minutes (0-59),

Clock.java - Write a class named Clock that contains the following variables, methods, and constructors:

A. Private instance variables that store hours (0-23), minutes (0-59), and seconds (0-59).

B. A constructor that initializes the hours, minutes, and seconds to values specified by parameters.

C. A constructor that initializes the hours, minutes to values specified by parameters (defaulting the seconds to 0).

D. A constructor that initializes the hours to a value specified by a parameter (defaulting the minutes and seconds to 0).

E. A no-arg constructor that sets the hours, minutes, and seconds to 0.

F. A method that resets the hours, minutes, and seconds to 0.

G. A method that advances the clock by one second.

H. Getters and setters for hours, minutes, and seconds.

I. A toString method that returns the hours, minutes, and seconds as a string of the form"hh:mm:ss".

TestClock.java - A driver class that contains only a main method that testing all constructors and methods in the class.

You need to add comments for methods and variables in the program.

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!