diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index d31a45c..27c74bf 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -3,6 +3,7 @@ import com.booleanuk.helpers.ExerciseBase; import java.util.ArrayList; +import java.util.List; public class Exercise extends ExerciseBase { /* @@ -44,6 +45,10 @@ public ArrayList getFavouriteNumbers() { second number contained in the list that is returned from getFavouriteNumbers */ + public int getSecondNumber() { + return getFavouriteNumbers().get(1); + } + /* @@ -55,7 +60,10 @@ public ArrayList getFavouriteNumbers() { Use the ArrayList's replaceAll method to iterate through the ArrayList and replace each value with its double https://www.programiz.com/java-programming/library/arraylist/replaceall */ - + public ArrayList multiply(ArrayList list, int num) { + list.replaceAll(x -> x * num); + return list; + } /* @@ -63,6 +71,9 @@ public ArrayList getFavouriteNumbers() { - A list of strings The method must return a boolean that indicates whether the provided list is empty or not */ + public boolean isEmpty(ArrayList list) { + return list.isEmpty(); + } @@ -72,7 +83,10 @@ public ArrayList getFavouriteNumbers() { - A string The method must add the second parameter into the list provided and then return the list */ - + public ArrayList addIngredient(ArrayList list, String word) { + list.add(word); + return list; + } /* @@ -81,7 +95,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; + } /* @@ -91,6 +108,10 @@ public ArrayList getFavouriteNumbers() { 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); + } + }