Class Timer

java.lang.Object
  extended by Timer
Direct Known Subclasses:
NamedTimer

public class Timer
extends java.lang.Object

A countdown timer with minutes and seconds. The timer does not go less than zero.


Constructor Summary
Timer()
          construct a timer with no initial value; timer set to zero
Timer(int minutes)
          construct a timer with a positive number of minutes
Timer(int minutes, int seconds)
          construct a timer with minutes and seconds of timer (combined value should be positive)
 
Method Summary
 boolean outOfTime()
          returns whether timer has run out of time
 void set()
          sets timer to zero
 void set(int minutes)
          sets minutes of timer (value should be positive)
 void set(int minutes, int seconds)
          sets minutes and seconds of timer (combined value should be positive)
 void subtract(int minutes, int seconds)
          subtracts minutes and seconds from timer; timer should not fall below zero
 java.lang.String toString()
          builds a string of the timer's value in minutes:seconds form
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Timer

public Timer(int minutes,
             int seconds)
construct a timer with minutes and seconds of timer (combined value should be positive)

Parameters:
minutes - number of minutes on newly constructed timer
seconds - number of seconds on newly constructed timer

Timer

public Timer(int minutes)
construct a timer with a positive number of minutes

Parameters:
minutes - number of minutes on newly constructed timer

Timer

public Timer()
construct a timer with no initial value; timer set to zero

Method Detail

set

public void set(int minutes,
                int seconds)
sets minutes and seconds of timer (combined value should be positive)

Parameters:
minutes - number of minutes
seconds - number of seconds

set

public void set(int minutes)
sets minutes of timer (value should be positive)

Parameters:
minutes - number of minutes

set

public void set()
sets timer to zero


toString

public java.lang.String toString()
builds a string of the timer's value in minutes:seconds form

Overrides:
toString in class java.lang.Object
Returns:
a string of the timer's value in minutes:seconds form

subtract

public void subtract(int minutes,
                     int seconds)
subtracts minutes and seconds from timer; timer should not fall below zero

Parameters:
minutes - number of minutes to subtract
seconds - number of seconds to subtract

outOfTime

public boolean outOfTime()
returns whether timer has run out of time

Returns:
whether timer has run out of time