Class ClockDisplay

java.lang.Object
  extended by ClockDisplay

public class ClockDisplay
extends java.lang.Object

The ClockDisplay class implements a digital clock display for a European-style 24 hour clock. The clock shows hours, minutes and seconds. The range of the clock is 00:00:00 (midnight) to 23:59:59 (one second before midnight). The clock display receives "ticks" (via the timeTick method) every second and reacts by incrementing the display. This is done in the usual clock fashion: the hour increments when the minutes roll over to zero and the minute increments when the seconds roll over to zero.

Version:
2008.03.30
Author:
Michael Kolling and David J. Barnes

Constructor Summary
ClockDisplay()
          Constructor for ClockDisplay objects.
ClockDisplay(int hour, int minute, int second)
          Constructor for ClockDisplay objects.
 
Method Summary
 java.lang.String getTime()
          Return the current time of this display in the format HH:MM:SS.
 void setTime(int hour, int minute, int second)
          Set the time of the display to the specified hour, minute and second.
 void timeTick()
          This method should get called once every second - it makes the clock display go one second forward.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClockDisplay

public ClockDisplay()
Constructor for ClockDisplay objects. This constructor creates a new clock set at 00:00:00.


ClockDisplay

public ClockDisplay(int hour,
                    int minute,
                    int second)
Constructor for ClockDisplay objects. This constructor creates a new clock set at the time specified by the parameters.

Method Detail

getTime

public java.lang.String getTime()
Return the current time of this display in the format HH:MM:SS.


setTime

public void setTime(int hour,
                    int minute,
                    int second)
Set the time of the display to the specified hour, minute and second.


timeTick

public void timeTick()
This method should get called once every second - it makes the clock display go one second forward.