diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 7ac3cfb..5e05dbc 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -2,6 +2,8 @@ import com.booleanuk.helpers.ExerciseBase; +import java.util.stream.IntStream; + public class Exercise extends ExerciseBase { /* A method is a function, a single piece of logic that can run. In Java, a class is a convenient @@ -35,7 +37,7 @@ public String greet(String name) { Complete this method so that it increases the number given by 1 and returns the result */ public int increment(int number) { - return 0; + return number+1; } /* @@ -48,8 +50,8 @@ public int increment(int number) { Nathan | Hi, Nathan :) Edward | Hi, Edward :) */ - public String happilyGreet() { - return "Not implemented yet"; + public String happilyGreet(String name) { + return "Hi, " + name + " :)"; } /* @@ -65,6 +67,13 @@ public String happilyGreet() { -1, 1 | [-1,0,1] */ + public int[] constructNumberArray(int lower, int upper){ + int[] arr = IntStream.range(lower, upper+1).toArray(); + for(int i : arr){ + System.out.println(i); + } + return arr; + } @@ -81,7 +90,8 @@ The method must return the same string in upper case with exclamation marks (!) error, 10 | ERROR!!!!!!!!!! */ - - + public String shout(String s, int marks){ + return s.toUpperCase() + "!".repeat(Math.max(0, marks)); + } }