Write a Java class named Clock.java that contains the following variables, methods, and constructors: 1. Private instance variables that store hours (0-23), minutes (0-59), and seconds (0-59). 2. A constructor that initializes the hours, minutes, and seconds to values specified by parameters. 3. A constructor that initializes the hours, minutes to values specified by parameters (defaulting the seconds to 0) 4. A constructor that initializes the hours to a value specified by a parameter (defaulting the minutes and seconds to 0) 5. A no-arg constructor that sets the hours, minutes, and seconds to 0. 6. A method that resets the hours, minutes, and seconds to 0. 7. A method that advances the clock by one second. 8. Getters and setters for hours, minutes, and seconds. 9. A toString method that returns the hours, minutes, and seconds as a string of the form "hh:mm:ss".
Write a Java class named Clock.java that contains the following variables, methods, and constructors:
1. Private instance variables that store hours (0-23), minutes (0-59), and seconds (0-59).
2. A constructor that initializes the hours, minutes, and seconds to values specified by parameters.
3. A constructor that initializes the hours, minutes to values specified by parameters (defaulting the seconds to
0)
4. A constructor that initializes the hours to a value specified by a parameter (defaulting the minutes and seconds to 0)
5. A no-arg constructor that sets the hours, minutes, and seconds to 0.
6. A method that resets the hours, minutes, and seconds to 0.
7. A method that advances the clock by one second.
8. Getters and setters for hours, minutes, and seconds.
9. A toString method that returns the hours, minutes, and seconds as a string of the form "hh:mm:ss".
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images