Class Counter

java.lang.Object
  extended by Counter

public class Counter
extends java.lang.Object

A Counter, with the ability to wrap and set the max value


Constructor Summary
Counter()
          Constructor taking no parameters, setting the default max value of 59
Counter(int max)
          Constructor setting the max value Throws on non-positive integers.
 
Method Summary
 void down()
          Decrement counter by one
 boolean equals(java.lang.Object rhs)
          Does this counter equal another one?
static int nbrOfCounters()
          Get number of counters
 void reset()
          Reset counter to zero
 void setCounter(int t)
          Set counter to a value.
 java.lang.String toString()
          Return a string
 void up()
          Increment counter by one
 int whatIsCounter()
          Get counter value
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Counter

public Counter()
Constructor taking no parameters, setting the default max value of 59


Counter

public Counter(int max)
Constructor setting the max value Throws on non-positive integers.

Parameters:
max - maximum count number
Method Detail

up

public void up()
Increment counter by one


down

public void down()
Decrement counter by one


reset

public void reset()
Reset counter to zero


setCounter

public void setCounter(int t)
Set counter to a value. Throws on non-positive integers, wraps on too large numbers.

Parameters:
t - value to set counter to

whatIsCounter

public int whatIsCounter()
Get counter value

Returns:
counter value

nbrOfCounters

public static int nbrOfCounters()
Get number of counters

Returns:
number of counters

equals

public boolean equals(java.lang.Object rhs)
Does this counter equal another one?

Overrides:
equals in class java.lang.Object
Parameters:
rhs - Object to compare to
Returns:
true if they equal

toString

public java.lang.String toString()
Return a string

Overrides:
toString in class java.lang.Object
Returns:
a string