diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 7ac3cfb..32d4950 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.Arrays; + 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,10 @@ 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; + + number++; + + return number; } /* @@ -48,8 +53,11 @@ 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,6 +72,17 @@ public String happilyGreet() { 10, 13 | [10,11,12,13] -1, 1 | [-1,0,1] */ + //denna + public int[] constructNumberArray (int lower, int upper) { + int[] myArray = new int[upper-lower+1]; + myArray[0] = lower; + myArray[myArray.length-1] = upper; + + for (int i = 0; i < (myArray.length-1); i ++) { + myArray[i+1] = myArray[i]+1; + } + return myArray; + } @@ -80,6 +99,14 @@ The method must return the same string in upper case with exclamation marks (!) disaster, 5 | DISASTER!!!!! error, 10 | ERROR!!!!!!!!!! */ + public String shout (String string, int number) { + + string = string.toUpperCase(); + for (int i = 0; i < number; i++) { + string = string.concat("!"); + } + return string; + } diff --git a/src/main/java/com/booleanuk/extension/Extension.java b/src/main/java/com/booleanuk/extension/Extension.java index f9de7dd..f52e77a 100644 --- a/src/main/java/com/booleanuk/extension/Extension.java +++ b/src/main/java/com/booleanuk/extension/Extension.java @@ -9,6 +9,10 @@ public class Extension extends ExtensionBase { 5. Create a method named bakingTime that returns the number 50 */ + public int bakingTime () { + return 50; + } + @@ -20,6 +24,10 @@ public class Extension extends ExtensionBase { and the result of calling the bakingTime method */ + public int remainingBakeTime (int numOfMinutes) { + return 50 - numOfMinutes; + } + @@ -30,6 +38,10 @@ 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) { + int prepTime = layers * 3; + return prepTime; + } @@ -43,7 +55,12 @@ 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 ovenMin) { + int timeToCook = calculatePrepTime(layers); + int remainingTime = timeToCook + ovenMin; + return remainingTime; + }