diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 7ac3cfb..7988cb5 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -35,7 +35,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 +48,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 + " :)"; } /* @@ -64,7 +64,14 @@ public String happilyGreet() { 10, 13 | [10,11,12,13] -1, 1 | [-1,0,1] */ - + public int[] constructNumberArray(int lower, int upper) { + int[] result = new int[upper - lower + 1]; + for(int i = 0; i < result.length; i++) { + result[i] = lower; + lower++; + } + return result; + } @@ -80,7 +87,13 @@ The method must return the same string in upper case with exclamation marks (!) disaster, 5 | DISASTER!!!!! error, 10 | ERROR!!!!!!!!!! */ - + public String shout(String shout, int num) { + String exclamation = ""; + for (int i = 0; i < num; i++) { + exclamation += "!"; + } + return shout.toUpperCase() + exclamation; + } diff --git a/src/main/java/com/booleanuk/extension/Extension.java b/src/main/java/com/booleanuk/extension/Extension.java index f9de7dd..04a2081 100644 --- a/src/main/java/com/booleanuk/extension/Extension.java +++ b/src/main/java/com/booleanuk/extension/Extension.java @@ -8,7 +8,9 @@ public class Extension extends ExtensionBase { /* 5. Create a method named bakingTime that returns the number 50 */ - + public int bakingTime() { + return 50; + } @@ -19,7 +21,9 @@ public class Extension extends ExtensionBase { It must return how many minutes are left to bake based on the input and the result of calling the bakingTime method */ - + public int remainingBakeTime(int min) { + return bakingTime() - min; + } @@ -30,7 +34,9 @@ public class Extension extends ExtensionBase { It must return how many minutes it will take to prepare the cake based on each layer taking 3 minutes to prepare */ - + public int calculatePrepTime(int layers) { + return layers * 3; + } @@ -43,7 +49,9 @@ public class Extension extends ExtensionBase { which is the sum of the preparation time and the number of minutes it's been in the oven. Use your calculatePrepTime method in the calculation */ - + public int totalTimeSpent(int layers, int min) { + return calculatePrepTime(layers) + min; + }