Question: 2. Consider a class Time that represents a time of day. It has attributes for the hour and minute. The hour value ranges from 0

 2. Consider a class Time that represents a time of day.

2. Consider a class Time that represents a time of day. It has attributes for the hour and minute. The hour value ranges from 0 to 23, where the range 0 to 11 represents a time before noon. The minute value ranges from 0 to 59. a. Write a default constructor that initializes the time to 0 hours, 0 minutes. b. Write a private method isValidChour, minute) that returns true if the c. Write a method setTime(hour, minute) that sets the time if the given given hour and minute values are in the appropriate range. values are valid. CHAPTER 6/ More About Objects and Methods d. Write another method setTime(hour, minute, isAM) that sets the time if the given values are valid. The given hour should be in the range 1 to 12. The parameter isAm is true if the time is an a.m. time and false otherwise

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!