Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions src/main/java/com/booleanuk/core/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.booleanuk.helpers.ExerciseBase;

import java.util.ArrayList;
import java.util.List;

public class Exercise extends ExerciseBase {
/*
Expand Down Expand Up @@ -39,12 +40,19 @@ public ArrayList<Integer> getFavouriteNumbers() {
return list;
}

public int getSecondNumber() {
return getFavouriteNumbers().get(1);
}

/*
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 ArrayList<Integer> multiply(ArrayList<Integer> inputList, int inputNum) {
inputList.replaceAll(e -> e*inputNum);
return inputList;
}

/*
TODO: 2. Create a method named multiply that accepts two parameters in this order:
Expand All @@ -56,15 +64,20 @@ public ArrayList<Integer> getFavouriteNumbers() {
https://www.programiz.com/java-programming/library/arraylist/replaceall
*/


public boolean isEmpty(ArrayList<String> inputList) {
return inputList.isEmpty();
}

/*
TODO: 3. Create a method named isEmpty that accepts one parameter:
- A list of strings
The method must return a boolean that indicates whether the provided list is empty or not
*/


public ArrayList<String> addIngredient(ArrayList<String> inputList, String ingredient) {
inputList.add(ingredient);
return inputList;
}

/*
TODO: 4. Create a method named addIngredient that accepts two parameters in this order:
Expand All @@ -74,7 +87,10 @@ public ArrayList<Integer> getFavouriteNumbers() {
*/



public ArrayList<String> removeIngredient(ArrayList<String> strings, String string) {
strings.remove(1);
return strings;
}
/*
TODO: 5. Create a method named removeIngredient that accepts two parameters in this order:
- A list of strings
Expand All @@ -83,7 +99,12 @@ public ArrayList<Integer> getFavouriteNumbers() {
*/



public boolean containsIngredient(ArrayList<String> strings, String string) {
for (String s : strings) {
if (s.equals(string)) return true;
}
return false;
}
/*
TODO: 6. Create a method named containsIngredient that accepts two parameters in this order:
- A list of strings
Expand Down
Loading