import counters.SimpleCounter; import counters.LimitReachedException; /** * * Test of the counters package. * */ public class counterTest { public static void main(String[] args) { SimpleCounter testCounter; testCounter = new SimpleCounter(5); System.out.print("Counter limit: "); System.out.printf("%1d", testCounter.getLimit()); System.out.println(""); System.out.println(""); System.out.print("Counter value: "); System.out.printf("%1d", testCounter.getValue()); System.out.println(""); System.out.println(""); try { for (int i=0; i<= 6; i++) { System.out.println("Trying to increase counter value."); testCounter.advanceValue(); System.out.print("Counter value: "); System.out.printf("%1d", testCounter.getValue()); System.out.println(""); System.out.println(""); }; } catch (LimitReachedException ex) { System.out.println("Counter has reached its limit."); } }; }