In the following
Timeand
TimeDriverclass skeletons, replace the italicized
a) In the
Timeclass, provide a method definition for thesetHoursmethod such that setHours can be called as part of a method-call chain.b) In the
TimeDriverclass, provide a single statement that chains calls to thesetHours, set-Minutes, setSeconds,andprintTimemethods. Use reasonable values for your method-call arguments. If you pass 8 tosetHours, 59 tosetMinutes, and 0 tosetSeconds, then your method-call-chaining statement should print this:08:59:00public class Time{ private int hours; private int minutes; private int seconds; //**********************************************************<insert setHours method definition here>
public Time setMinutes(int minutes) { this.minutes = minutes; return this; } // end setMinutes public 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();<insert chained-method-calls statement here>
}} // end TimeDriver class
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.