Question: Write a class named Clock that meets the following requirements: The class has two instance variables: a type int called hour, a type int called

Write a class named Clock that meets the following requirements: The class has two instance variables: a type int called hour, a type int called minute. The class has a constructor that takes two parameters: an int for an hour, an int for a minute. The constructor constructs a Clock with the specified values. A method named increment with no arguments and no return value. It increases the minute by 1 if the minute is less than 60. A method named decrement with no arguments and no return value. It decreases the minute by 1 if minute is greater than 0. The hour and minute are changed accordingly as the increment or decrement methods change the minute. Write a test program that creates a Clock with XP12 hour 10, minute 57, and then invokes the increment method five and then displays the current hour and minute; invoke the decrement method ten times and then displays the current hour and minute.

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 Programming Questions!