@Test public void shouldReturnAnEmptyCollectionIfArrayOfMoneysIsEmpty() { List<List<Integer>> combinations = combinationsOfChange.get(new int[0], 1); assertTrue(combinations.isEmpty()); }
public List<List<Integer>> get(int[] availableChange, int value) { validateInputData(availableChange, value); List<List<Integer>> changeCombinations = new LinkedList<List<Integer>>(); for (int i = 0; i < availableChange.length; i++) { int[] availableMoneys = Arrays.copyOfRange(availableChange, 0, availableChange.length - i); List<Integer> change = getChange(availableMoneys, value); changeCombinations.add(change); } return changeCombinations; }
CombinationsOfChange { public List<List<Integer>> get(int[] availableChange, int value) { validateInputData(availableChange, value); List<List<Integer>> changeCombinations = new LinkedList<List<Integer>>(); for (int i = 0; i < availableChange.length; i++) { int[] availableMoneys = Arrays.copyOfRange(availableChange, 0, availableChange.length - i); List<Integer> change = getChange(availableMoneys, value); changeCombinations.add(change); } return changeCombinations; } }
CombinationsOfChange { public List<List<Integer>> get(int[] availableChange, int value) { validateInputData(availableChange, value); List<List<Integer>> changeCombinations = new LinkedList<List<Integer>>(); for (int i = 0; i < availableChange.length; i++) { int[] availableMoneys = Arrays.copyOfRange(availableChange, 0, availableChange.length - i); List<Integer> change = getChange(availableMoneys, value); changeCombinations.add(change); } return changeCombinations; } CombinationsOfChange(); }
CombinationsOfChange { public List<List<Integer>> get(int[] availableChange, int value) { validateInputData(availableChange, value); List<List<Integer>> changeCombinations = new LinkedList<List<Integer>>(); for (int i = 0; i < availableChange.length; i++) { int[] availableMoneys = Arrays.copyOfRange(availableChange, 0, availableChange.length - i); List<Integer> change = getChange(availableMoneys, value); changeCombinations.add(change); } return changeCombinations; } CombinationsOfChange(); List<List<Integer>> get(int[] availableChange, int value); }
CombinationsOfChange { public List<List<Integer>> get(int[] availableChange, int value) { validateInputData(availableChange, value); List<List<Integer>> changeCombinations = new LinkedList<List<Integer>>(); for (int i = 0; i < availableChange.length; i++) { int[] availableMoneys = Arrays.copyOfRange(availableChange, 0, availableChange.length - i); List<Integer> change = getChange(availableMoneys, value); changeCombinations.add(change); } return changeCombinations; } CombinationsOfChange(); List<List<Integer>> get(int[] availableChange, int value);  }