coins.driver
Class StopWatch

java.lang.Object
  extended bycoins.driver.StopWatch

public class StopWatch
extends java.lang.Object

A stop-watch.
This stop-watch is not moving when created, and starts when its start button is pushed. Its hand keeps moving until the stop button is pushd. You can read the time ever accumulated by this stop-watch, by mili-second order, whether it is moving or not. After the stop-watch is started and stopped, it can be restarted by pushing its start button again.


Field Summary
(package private)  long cumulativeMiliSeconds
           
(package private)  boolean moving
           
(package private)  java.util.Date startedTime
           
(package private)  java.util.Date stoppedTime
           
 
Constructor Summary
StopWatch()
          Creates a new stop-watch, whose hand is heading zero mili-second and not moving.
 
Method Summary
 boolean isMoving()
          Tests if this stop-watch is moving or not.
 long read()
          Reads this stop-watch, whether it is moving or not.
 long reset()
          Resets this stop-watch.
 java.util.Date start()
          Starts moving this stop-watch.
 java.util.Date stop()
          Stops moving this stop-watch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

startedTime

java.util.Date startedTime

stoppedTime

java.util.Date stoppedTime

cumulativeMiliSeconds

long cumulativeMiliSeconds

moving

boolean moving
Constructor Detail

StopWatch

public StopWatch()
Creates a new stop-watch, whose hand is heading zero mili-second and not moving.

Method Detail

start

public java.util.Date start()
Starts moving this stop-watch.

Returns:
The time this stop-watch was started, if it was already moving. null, otherwise.

stop

public java.util.Date stop()
Stops moving this stop-watch.

Returns:
The time this stop-watch was stopped, if it was already stopped. null, otherwise.

read

public long read()
Reads this stop-watch, whether it is moving or not.

Returns:
the mili-seconds ever accumulated by this stop-watch.

isMoving

public boolean isMoving()
Tests if this stop-watch is moving or not.

Returns:
true if it is moving. false, otherwise.

reset

public long reset()
Resets this stop-watch. The hand goes back to zero mili-second and stops moving regardless of the current status.

Returns:
the cumulative mili-seconds before resetting.