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