/** * Counter is a non-negative Integer with restricted operations for counting. * * @author J. Dalbey * @version 3/8/2010 */ public class Counter { // counter value private int count; // ending value (optional) private int target; /** * Default Constructor sets counter to zero. */ public Counter() { count = 0; } /** * Constructor with a target end value. * @param end is the ending value * @pre end > 0 */ public Counter(int end) { this(); target = end; } /** * Increment by one. */ public void inc() { count = count + 1; } /** * Check if counter has not reached the target. * @return true if count not equals target, false otherwise */ public boolean notDone() { return count != target; } }