package rebelsky.fractions; /** * A counter that permits you to specify a starting value. * * @author Samuel A. Rebelsky * @version 1.0 of September 2005 */ public class ExtendedCounter { // +--------------+------------------------------------------------------ // | Class Fields | // +--------------+ // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** * The count. */ int count; /** * The starting value. */ int start; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Create a new counter which starts at 0. */ public ExtendedCounter() { this.count = 0; this.start = 0; } // ExtendedCounter() /** * Create a new counter which starts at _start. */ public ExtendedCounter(int _start) { this.count = _start; this.start = _start; } // ExtendedCounter() // +---------+----------------------------------------------------------- // | Methods | // +---------+ /** * Add one to the count. */ public void increment() { this.count = this.count + 1; } // increment() /** * Get the count. */ public int get() { return this.count; } // get() /** * Reset to the starting value. */ public void reset() { this.count = this.start; } // reset() // +---------------+----------------------------------------------------- // | Class Methods | // +---------------+ } // class ExtendedCounter