/**
 * A numerical counter. Has features that will increment by 1
 * or more than 1.
 */
public class Counter {

    /** The current value of the counter. */
    private int currentValue;
    
    /** The amount to increment the current value by. */
    private int increment = 1;
    
    /**
     * A <code>Counter</code> that starts at 0 and increments by 1.
     */
    public Counter() {
        /* Empty body! */
    }

    /**
     * A <code>Counter</code> that starts at <code>n</code> and
     * increments by 1.
     * @param n the initial value of this <code>Counter</code>.
     */
    public Counter(int n) {
        currentValue = n;
    }
    
    /**
     * A <code>Counter</code> that starts at <code>n</code>
     * and increments by <code>i</code>.
     * @param i the initial value of this <code>Counter</code>.
     * @param n the increment of this <code>Counter</code>.
     */
    public Counter(int n, int i) {
        currentValue = n;
        increment = i;
    }
    
    /**
     * Return this <code>Counter</code>'s current value.
     * @return this <code>Counter</code>'s current value.
     */
    public int currentValue() {
        return currentValue;
    }
    
    /**
     * Increment this <code>Counter</code> by its increment.
     */
    public void increment() {
        currentValue += increment;
    }
    
    /**
     * Return a <code>String</code> representation of
     * this <code>Counter</code>.
     * @return a <code>String</code> representation of
     * this <code>Counter</code>.
     */
    public String toString() {
        return "" + currentValue;
    }
    
    /**
     * = "this <code>Counter</code> is the same as <code>c</code>".
     * @param c the <code>Counter</code> to compare to this one.
     */
    public boolean equals(Counter c) {
        return c != null && currentValue == c.currentValue
            && increment == c.increment;
    }

}
