|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
antichess.GameTimer
public class GameTimer
The GameTimer stores a time that ticks down when GameTimer is running. GameTimer also stores a list of GameTimerListeners that it can notify of its time.
startTime
: long //
timeLeft
: long //The number of millseconds left on the timer
listenerList
: sequence // This GameTimer's listeners
isRunning
: boolean // Whether the clock is running
timeInterval
: long // the interval between updates on the clock
Constructor Summary | |
---|---|
GameTimer(long startTime,
long interval)
Creates a GameTimer with a start time and current time of startTime |
|
GameTimer(long startTime,
long currentTime,
long interval)
Creates a GameTimer with a start time of startTime, but a current time of currentTime |
Method Summary | |
---|---|
void |
addTimerListener(GameTimerListener listener)
|
long |
getStartTime()
|
long |
getTime()
|
boolean |
isRunning()
|
void |
notifyTimeUpdate()
Calls refreshTimer on all the listeners |
void |
run()
Refreshes the time for all the listeners |
void |
setTime(long newTime)
|
void |
start()
Starts the timer |
void |
stop()
Stops the timer |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GameTimer(long startTime, long interval)
startTime
- is the start time measured in milliseconds
interval is the interval between updates to the listeners of this timer
if interval is 0 the listeners are not updated
IllegalArgumentException
- if interval < 0 or startTimer < 0public GameTimer(long startTime, long currentTime, long interval)
startTime
- : the start time measured in millisecondscurrentTime
- : the remaining time in millisecondsinterval
- : the time between updates if interval is 0 the listeners are not updated
IllegalArgumentException
- if interval < 0 or startTimer < 0 or currentTime < 0Method Detail |
---|
public void start()
public void stop()
public long getStartTime()
public long getTime()
public void addTimerListener(GameTimerListener listener)
public boolean isRunning()
public void notifyTimeUpdate()
public void run()
run
in interface Runnable
run
in class TimerTask
public void setTime(long newTime)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |