Class Counter

java.lang.Object
  |
  +--Counter

public class Counter
extends java.lang.Object

A Counter is an object that counts integer values. It provides services to be reset, to be incremented and to retrieve its value


Constructor Summary
Counter()
          Constructs a counter with default value (0) and step (1).
Counter(int v)
          Constructs a counter providing a start value and a default step (1).
Counter(int v, int s)
          Constructs a counter providing a start value and a specific step.
 
Method Summary
 void dec()
          Decrements the counter value.
 void dec(int n)
          Decrements the counter value
 boolean equals(Counter x)
          Tests if two counters are equal.
 int getStep()
          Gets the counter step value.
 int getValue()
          Gets the counter value.
 void inc()
          Increments the counter value.
 void inc(int n)
          Increments the counter value
 void reset()
          Resets the counter value.
 void setLimits(int mi, int ma)
          Set the limits of the caunter, min e max.
 void setStep(int s)
          Set the counter step value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Counter

public Counter()
Constructs a counter with default value (0) and step (1).

Counter

public Counter(int v)
Constructs a counter providing a start value and a default step (1).

Counter

public Counter(int v,
               int s)
Constructs a counter providing a start value and a specific step.
Method Detail

reset

public void reset()
Resets the counter value. The value is reset to zero.

inc

public void inc()
Increments the counter value. The counter counts from min to max.

inc

public void inc(int n)
Increments the counter value
Parameters:
n - amount of the increment. The counter counts from min to max.

dec

public void dec()
Decrements the counter value. The counter counts from min to max.

dec

public void dec(int n)
Decrements the counter value
Parameters:
n - amount of the decrement. The counter counts from min to max.

getValue

public int getValue()
Gets the counter value.

getStep

public int getStep()
Gets the counter step value.

equals

public boolean equals(Counter x)
Tests if two counters are equal. Two counters are equal when they have the same value.

setStep

public void setStep(int s)
Set the counter step value.

setLimits

public void setLimits(int mi,
                      int ma)
Set the limits of the caunter, min e max.