chn.util
Class SysTimer

java.lang.Object
  |
  +--chn.util.SysTimer

public class SysTimer
extends java.lang.Object


Constructor Summary
SysTimer()
          Initializes state.
 
Method Summary
 double cumulativeTime()
           
 double elapsedTime()
          precondition: stopwatch is not running
 boolean isRunning()
           
 double lapTime()
           
static void main(java.lang.String[] args)
          tests functionality of the methods
 void reset()
          Resets the stopwatch.
 void start()
          Starts the stopwatch.
 void stop()
          Stops the stopwatch and sets elapsed time to be the time since the stopwatch was last started or reset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SysTimer

public SysTimer()
Initializes state.
Method Detail

start

public void start()
Starts the stopwatch. If it is already running, resets start time to current time. postcondition: stopwatch is running.

stop

public void stop()
Stops the stopwatch and sets elapsed time to be the time since the stopwatch was last started or reset. If it is not running, elapsed time is set to zero. postcondition: stopwatch is not running.

reset

public void reset()
Resets the stopwatch. postcondition: stopwatch is not running. elapsed time is zero cumulative time is zero

isRunning

public boolean isRunning()
Returns:
true if timer is running, false if not

lapTime

public double lapTime()
Returns:
time in seconds since stopwatch was last started, 0 if not running

elapsedTime

public double elapsedTime()
precondition: stopwatch is not running
Returns:
elapsed time in seconds, the time between the last start and stop if running, return zero.

cumulativeTime

public double cumulativeTime()
Returns:
total running time in seconds since stopwatch was last reset, including current lap time.

main

public static void main(java.lang.String[] args)
tests functionality of the methods