Skip to content
Open
Show file tree
Hide file tree
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
25 changes: 19 additions & 6 deletions src/main/java/com/booleanuk/core/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public HashMap<String, String> createPerson() {
in the createPerson method
*/

public String getValue(String key){
return createPerson().get(key);
}


/*
Expand All @@ -57,7 +60,9 @@ public HashMap<String, String> createPerson() {
The method must return a boolean that represents whether the string provided exists as a key
in the provided HashMap
*/

public boolean hasKey(HashMap<String,String> map, String string){
return map.containsKey(string);
}


/*
Expand All @@ -67,7 +72,12 @@ public HashMap<String, String> createPerson() {
The method must use the string provided to return the integer contained in the provided HashMap,
or -1 if the string provided is not a key in the HashMap
*/

public int getValueOrDefault (HashMap<String,Integer> map, String string) {
if(map.get(string) != null){
return map.get(string);
}
return -1;
}


/*
Expand All @@ -89,13 +99,16 @@ public ArrayList<String> buildSecretPhrase(ArrayList<Integer> numbers) {
map.put(7, "muse");
map.put(96, "nice");
// Write your code below this comment...
ArrayList<String> list = new ArrayList<>();




for (Integer number : numbers) {
if (map.get(number) != null) {
list.add(map.get(number));
}
}
// ...and above this comment

// Change the return statement below to return your actual ArrayList
return new ArrayList<String>();
return list;
}
}
2 changes: 1 addition & 1 deletion src/test/java/com/booleanuk/core/ExerciseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.ArrayList;
import java.util.HashMap;

class ExerciseTest {
class ExerciseTest {
Exercise exercise;

public ExerciseTest() {
Expand Down
Loading