// Filename BasicCounter.java. // Root class of the Counters hierarchy providing the // essential counting functionality. // // Written for JFL book Chapter 3. // Fintan Culwin, v0.1, January 1997 // Modified by X. Meng for package demonstartion // for CSCI 2320 Fall 1998 abstract class BasicCounter { private int counted = 0; private int theInitialCount = 0; // Principal constructor. protected BasicCounter( int initialCount) { counted = initialCount; theInitialCount = 0; } // End principal constructor. // Default constructor. protected BasicCounter() { this(0); } // End default constructor. protected void count() { counted++; } // End count. protected void unCount() { counted--; } // end unCount. protected void setCountTo( int setTo) { counted = setTo; } // End setCountTo. protected void reset() { counted = theInitialCount; } // End reset. public int numberCountedIs(){ return counted; } // End numberCountedIs. } // end class BasicCounter