Class Counter

java.lang.Object
  |
  +--Counter

public class Counter
extends java.lang.Object

Class Counter implements a simple counter.

Version:
v1.0, February 11, 2002
Author:
Antonios Symvonis

Constructor Summary
Counter()
          Set the initial value of the counter to zero
Counter(int initialValue)
          Set the initial value of the counter to a given value
 
Method Summary
 void decrement()
          Decrements the counter by one
 void decrementBy(int dec)
          Decrements the counter by a given value
 int getValue()
          Provides access to the value of the counter
 void increment()
          Increments the counter by one
 void incrementBy(int inc)
          Increments the counter by a given value
 void reset()
          Resets the counter to Zero
 void setValue(int newValue)
          Sets the counter to a new value
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Counter

public Counter()
Set the initial value of the counter to zero

Counter

public Counter(int initialValue)
Set the initial value of the counter to a given value
Parameters:
initialValue - the initial value of the counter
Method Detail

decrement

public void decrement()
Decrements the counter by one

decrementBy

public void decrementBy(int dec)
Decrements the counter by a given value
Parameters:
dec - The value the counter is decremented by.

getValue

public int getValue()
Provides access to the value of the counter
Returns:
The value of the counter

increment

public void increment()
Increments the counter by one

incrementBy

public void incrementBy(int inc)
Increments the counter by a given value
Parameters:
inc - The value the counter is incremented by.

reset

public void reset()
Resets the counter to Zero

setValue

public void setValue(int newValue)
Sets the counter to a new value
Parameters:
newValue - The new value of the counter


Generated by BlueJ