I\'ve been struggling with the creation of this code, especially because I still
ID: 3641048 • Letter: I
Question
I've been struggling with the creation of this code, especially because I still dont have a great understanding for java just yet. Please be as explanatory as possible... I really need help with this one.
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 isValid(hour, minute) that returns true if the given
hour and minute values are in the appropriate range.
c. Write a method setTime(hour, minute) that sets the time if the given values
are valid.
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.
Explanation / Answer
class Time{ private int hour; private int minute; public Time(){ hour = 0; minute = 0; } private boolean isValid(int hour, int minute){ return hour >=0 && hour =1 && hour =0 && minuteRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.