@Test public void get_ReturnExpectedPhoneNumbers() { PhoneNumberAllotter tested = new SimplePhoneNumberAllotter(5); assertEquals(0, tested.get()); assertEquals(4, tested.get(4)); assertEquals(2, tested.get()); assertEquals(3, tested.get()); assertEquals(1, tested.get()); }
@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; }