Problem

In the following Time and TimeDriver class skeletons, replace the italicized lines with y...

In the following Time and TimeDriver class skeletons, replace the italicized lines with your own code such that the program operates properly. More specifically:

a)In the Time class, provide a method definition for the setHours method such that setHours can be called as part of a method-call chain.


b)In the TimeDriver class, provide a single statement that chains calls to the setHours, set-Minutes, setSeconds, and printTime methods. Use reasonable values for your method-call arguments. If you pass 8 to setHours, 59 to setMinutes, and 0 to setSeconds, then your method-call-chaining statement should print this:

08:59:00public class Time{private int hours;private int minutes;private int seconds;//**********************************************************public Time setMinutes(int minutes){this.minutes = minutes;return this;} // end setMinutespublic Time setSeconds(int seconds){this.seconds = seconds;return this;} // end setSeconds//************************************************************public void printTime(){System.out.printf("%02d:%02d:%02d\n", hours, minutes, seconds);} // end printTime} // end Time classpublic class TimeDriver{public static void main(String[] args){Time time = new Time();}} // end TimeDriver class

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 7
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT