@Test public void get_RaiseErrorWhenNoNumbersAreLeft() { PhoneNumberAllotter tested = new SimplePhoneNumberAllotter(0); boolean thrown = false; try { tested.get(); } catch (NoNumbersLeftException e) { thrown = true; } assertTrue(thrown); }
@Override public int get() { if (next == phoneNumbers.length) { throw new NoNumbersLeftException("No phone numbers left."); } return phoneNumbers[next++]; }
SimplePhoneNumberAllotter implements PhoneNumberAllotter { @Override public int get() { if (next == phoneNumbers.length) { throw new NoNumbersLeftException("No phone numbers left."); } return phoneNumbers[next++]; } }
SimplePhoneNumberAllotter implements PhoneNumberAllotter { @Override public int get() { if (next == phoneNumbers.length) { throw new NoNumbersLeftException("No phone numbers left."); } return phoneNumbers[next++]; } SimplePhoneNumberAllotter(int size); }
SimplePhoneNumberAllotter implements PhoneNumberAllotter { @Override public int get() { if (next == phoneNumbers.length) { throw new NoNumbersLeftException("No phone numbers left."); } return phoneNumbers[next++]; } SimplePhoneNumberAllotter(int size); @Override int get(); @Override int get(int fancyNumber); }
SimplePhoneNumberAllotter implements PhoneNumberAllotter { @Override public int get() { if (next == phoneNumbers.length) { throw new NoNumbersLeftException("No phone numbers left."); } return phoneNumbers[next++]; } SimplePhoneNumberAllotter(int size); @Override int get(); @Override int get(int fancyNumber); public int[] phoneNumbers; }