@Test public void testGenerateBingoNumber() { for (int i = 1; i <= LARGEST_NUMBER; i++) { try { String result = generator.callBingoNumber(); assertNotNull(result); assertTrue(BINGO.contains(String.valueOf(result.charAt(0)))); assertTrue(Integer.parseInt(result.substring(1)) <= LARGEST_NUMBER); } catch (NoMoreBingoNumbersException ex) { assertEquals(LARGEST_NUMBER, i); } } }
public String callBingoNumber() throws NoMoreBingoNumbersException { if (numbersCalled.size() == LARGEST_NUMBER) { throw new NoMoreBingoNumbersException( "All possible Bingo numbers have been called."); } final int randomBingoNumberIndex = generator.nextInt(LARGEST_NUMBER); final String bingoNumber = BINGO_NUMBER_POOL[randomBingoNumberIndex % BUCKET_SIZE][randomBingoNumberIndex / BUCKET_SIZE]; if (numbersCalled.add(bingoNumber)) { return bingoNumber; } return callBingoNumber(); }
BingoNumberCaller { public String callBingoNumber() throws NoMoreBingoNumbersException { if (numbersCalled.size() == LARGEST_NUMBER) { throw new NoMoreBingoNumbersException( "All possible Bingo numbers have been called."); } final int randomBingoNumberIndex = generator.nextInt(LARGEST_NUMBER); final String bingoNumber = BINGO_NUMBER_POOL[randomBingoNumberIndex % BUCKET_SIZE][randomBingoNumberIndex / BUCKET_SIZE]; if (numbersCalled.add(bingoNumber)) { return bingoNumber; } return callBingoNumber(); } }
BingoNumberCaller { public String callBingoNumber() throws NoMoreBingoNumbersException { if (numbersCalled.size() == LARGEST_NUMBER) { throw new NoMoreBingoNumbersException( "All possible Bingo numbers have been called."); } final int randomBingoNumberIndex = generator.nextInt(LARGEST_NUMBER); final String bingoNumber = BINGO_NUMBER_POOL[randomBingoNumberIndex % BUCKET_SIZE][randomBingoNumberIndex / BUCKET_SIZE]; if (numbersCalled.add(bingoNumber)) { return bingoNumber; } return callBingoNumber(); }  }
BingoNumberCaller { public String callBingoNumber() throws NoMoreBingoNumbersException { if (numbersCalled.size() == LARGEST_NUMBER) { throw new NoMoreBingoNumbersException( "All possible Bingo numbers have been called."); } final int randomBingoNumberIndex = generator.nextInt(LARGEST_NUMBER); final String bingoNumber = BINGO_NUMBER_POOL[randomBingoNumberIndex % BUCKET_SIZE][randomBingoNumberIndex / BUCKET_SIZE]; if (numbersCalled.add(bingoNumber)) { return bingoNumber; } return callBingoNumber(); }  String callBingoNumber(); Set<String> getNumbersCalled(); boolean isCalled(String bingoNumber); }
BingoNumberCaller { public String callBingoNumber() throws NoMoreBingoNumbersException { if (numbersCalled.size() == LARGEST_NUMBER) { throw new NoMoreBingoNumbersException( "All possible Bingo numbers have been called."); } final int randomBingoNumberIndex = generator.nextInt(LARGEST_NUMBER); final String bingoNumber = BINGO_NUMBER_POOL[randomBingoNumberIndex % BUCKET_SIZE][randomBingoNumberIndex / BUCKET_SIZE]; if (numbersCalled.add(bingoNumber)) { return bingoNumber; } return callBingoNumber(); }  String callBingoNumber(); Set<String> getNumbersCalled(); boolean isCalled(String bingoNumber); static final String[][] BINGO_NUMBER_POOL; }