/** * Keeps track of what numbers have been called * in a game of bingo. * @author Jeff Raab */ public class BingoNumbers { /** What numbers have been called. */ protected boolean[] called; /** Constructs a new bingo numbers object. */ public BingoNumbers() { called = new boolean[76]; } /** * Stores the fact that the given number has been called. * @param num number to call */ public void call(int num) { if ((num < 1) || (num > 75)) { throw new RuntimeException("Number out of range"); } if (isCalled(num)) { throw new RuntimeException("Number already called"); } called[num] = true; } /** * Returns whether or not the given number is called. * @param num number to check */ public boolean isCalled(int num) { if ((num < 1) || (num > 75)) { throw new RuntimeException("Number out of range"); } return called[num]; } /** Sets that no numbers have been called. */ public void newGame() { for (int i = 0; i < called.length; i++) { called[i] = false; } } }