Class Time

java.lang.Object
  |
  +--Time
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class Time
extends java.lang.Object
implements java.awt.event.ActionListener

The Time class is the total time spent solving a map.


Constructor Summary
Time()
          Constructor - initializes the timer
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Required for the ActionListener interface.
 int getTime()
          Returns the current time in seconds.
 boolean isPaused()
          Returns the true if the time is paused, otherwise false.
 void reset()
          The total time is reset to 0.
 void setTime(int newTime)
          The total time is set to the time value passed.
 void start()
          Starts the timer so that the actionPerformed method will be called once every second.
 void stop()
          Stops the timer from firing ActionEvents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Time

public Time()
Constructor - initializes the timer
Method Detail

start

public void start()

Starts the timer so that the actionPerformed method will be called once every second.

Pre-condition:the timer has been initialized.
Post-condition:the timer is started and firing ActionEvents.

stop

public void stop()

Stops the timer from firing ActionEvents.

Pre-condition:the timer is started and firing ActionEvents.
Post-condition:the timer is stopped.

reset

public void reset()

The total time is reset to 0.

Pre-condition:none.
Post-condition:the time is set to 0.

setTime

public void setTime(int newTime)

The total time is set to the time value passed.

Parameters:
newTime - the time to set the new time to

isPaused

public boolean isPaused()
Returns the true if the time is paused, otherwise false.
Returns:
true if paused, false if running

getTime

public int getTime()

Returns the current time in seconds.

Returns:
Returns an integer representing the current time in seconds.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)

Required for the ActionListener interface. actionPerformed is called every time the timer fires an ActionEvent, once per second.

Pre-condition:the timer is started and firing ActionEvents.
Post-condition:the time is incremented.
Specified by:
actionPerformed in interface java.awt.event.ActionListener