Question: / * * Constructor for ClockDisplay objects. This constructor * creates a new clock and set at 0 0 : 0 0 : 0 0
Constructor for ClockDisplay objects. This constructor
creates a new clock and set at ::
public ClockDisplay
hours new NumberDisplay;
minutes new NumberDisplay;
seconds new NumberDisplay; create a new NumberDisplay for seconds with limit
updateDisplay;
Constructor for ClockDisplay objects. This constructor
creates a new clock set at the time specified by the parameters.
Add parameter for seconds
public ClockDisplayint hour, int minute, int second
hours new NumberDisplay;
minutes new NumberDisplay;
seconds new NumberDisplay;
setTimehour minute, second;
This method should get called once every second it makes
the clock display go one second forward
public void timeTick
seconds.increment; increment seconds
ifsecondsgetVaue seconds just rolled over?
minutes.increment; increment the minutes
ifminutesgetVaue minutes just rolled over?
hours.increment; increment the hours
updateDisplay;
Set the time of the display to the specified hour, minute and second
Add second parameter to the method
public void setTimeint hour, int minute, int second
hours.setValuehour;
minutes.setValueminute;
seconds.setValuesecond;
updateDisplay;
Return the current time if this display in the format HH:MM:SS
public String getTime
return displayString;
Update the internal string that represents the display
Add seconds display to include seconds in the time
private void updateDisplay
displayString hours.getDisplayValue: minutes.getDisplayValue:
seconds.getDisplayValue;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
