diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index d31a45c..f4e83a7 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -43,7 +43,10 @@ public ArrayList getFavouriteNumbers() { TODO: 1. Create a method named getSecondNumber that returns a whole number. It must return the second number contained in the list that is returned from getFavouriteNumbers */ - + public int getSecondNumber() { + ArrayList favourites = getFavouriteNumbers(); + return favourites.get(1); + } /* @@ -55,7 +58,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 numberList, int wholeNumber) { + numberList.replaceAll(e -> e * wholeNumber); + return numberList; + } /* @@ -63,7 +69,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 stringList) { + return stringList.isEmpty(); + } /* @@ -72,7 +80,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 ingredients, String ingredient) { + ingredients.add(ingredient); + return ingredients; + } /* @@ -81,7 +92,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 ingredients, String ingredient) { + ingredients.remove(1); + return ingredients; + } /* @@ -90,7 +104,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 ingredients, String ingredient) { + return ingredients.contains(ingredient); + } }