diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 7987028..dd89f18 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -51,20 +51,27 @@ public Exercise(int age) { Create a constructor that accepts both a String and an int as parameters, in that order, and assign the values provided to the name and age members */ - + public Exercise(String name, int age) { + this.name = name; + this.age = age; + } /* 2. Create a method named add that accepts two integers. The method should return the numbers added together. */ - + public int add(int one, int two) { + return Integer.sum(one, two); + } /* 3. Create another method named add that accepts two Strings. The method should return the strings concatenated together with a space in between. */ - + public String add(String one, String two) { + return one.concat(" "+two); + } } diff --git a/src/main/java/com/booleanuk/extension/Extension.java b/src/main/java/com/booleanuk/extension/Extension.java index 62b878f..8dd41bf 100644 --- a/src/main/java/com/booleanuk/extension/Extension.java +++ b/src/main/java/com/booleanuk/extension/Extension.java @@ -26,5 +26,17 @@ public class Extension extends ExtensionBase { multiply(["2", "7", "3"], 3) -> [6, 21, 9] */ + public String multiply (String s, int i) { + String test = ""; + for (int x = 0; x < i; x++) { + if (x != i-1) { + test = test + s+ ','; + } else { + test = test + s; + } + } + return test; + } + }