diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index d31a45c..ffcca9a 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -44,6 +44,11 @@ public ArrayList getFavouriteNumbers() { second number contained in the list that is returned from getFavouriteNumbers */ + public int getSecondNumber() { + ArrayList list = getFavouriteNumbers(); + return list.get(1); + } + /* @@ -56,6 +61,11 @@ public ArrayList getFavouriteNumbers() { https://www.programiz.com/java-programming/library/arraylist/replaceall */ + public ArrayList multiply(ArrayList list, int num) { + list.replaceAll(integer -> integer * num); + return list; + } + /* @@ -64,6 +74,10 @@ public ArrayList getFavouriteNumbers() { The method must return a boolean that indicates whether the provided list is empty or not */ + public boolean isEmpty(ArrayList list) { + return list.isEmpty(); + } + /* @@ -73,6 +87,11 @@ public ArrayList getFavouriteNumbers() { The method must add the second parameter into the list provided and then return the list */ + public ArrayList addIngredient(ArrayList list, String ingredient) { + list.add(ingredient); + return list; + } + /* @@ -81,6 +100,10 @@ public ArrayList getFavouriteNumbers() { - A string The method must remove the second parameter from the list and then return the list */ + public ArrayList removeIngredient(ArrayList list, String ingredient) { + list.remove(ingredient); + return list; + } @@ -90,6 +113,9 @@ public ArrayList getFavouriteNumbers() { - A string The method must return a boolean that indicates whether the second parameter exists in the provided list */ + public boolean containsIngredient(ArrayList list, String ingredient) { + return list.contains(ingredient); + }