Answered step by step
Verified Expert Solution
Question
1 Approved Answer
After this, we need to test our clock in a tester class. Use the default constructor, prompt user to input specified time (hrs, mins, and
After this, we need to test our clock in a tester class. Use the default constructor, prompt user to input specified time (hrs, mins, and seconds). reset using reset method. print results. Advance it by one second and reprint.
Let's use your calendarDate class from last week as a guide to create a Clock class. Create a file named Clock.java. Here, we want to create an instance class named Clock that contains the following variables, methods, and constructors: Private instance variables that store hours (0-23), minutes (0-59), and seconds (0-59). A constructor that initializes the hours, minutes, and seconds to values specified by the parameters. A default constructor with no parameters that sets the hours, minutes, and seconds to 0. A method named reset that resets the hours, minutes, and seconds to 0. It will have no parameters. . An overloaded reset method that resets the hours, minutes, and seconds to values specified by the parameters. It will have three parameters. A method named advance that advances the clock by one second. If seconds has now reached 60. reset seconds to 0, and increment the minutes. If, after incrementing minutes, minutes has now reached 60. reset minutes to 0, and increment the hours. If, after incrementing hours, hours has now reached 24, reset hours to 0. A toString method that returns hours, minutes, and seconds as a string of the form "h:m:s" You should end up with a total of 6 public methods, and 3 private attributes. Compile your ving on to test itStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started