/** * Encapsulate a tally counter/clicker-counter */ public class ClickerCounter { // Member variables private int count; private int maxCount; // Accessors and mutators public int getCount() { return count; } public void setMaxCount(int newMax) { if (newMax > 0) { maxCount = newMax; } else { System.out.println("Invalid maximum count: " + newMax); } } // Interface methods public void click() { if (count < maxCount) { count++; } else { count = 0; } } public void reset() { count = 0; } }