diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 7987028..4ec8750 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -51,20 +51,22 @@ 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 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 + " " + two; + } +} \ No newline at end of file diff --git a/src/main/java/com/booleanuk/extension/Extension.java b/src/main/java/com/booleanuk/extension/Extension.java index 62b878f..04808fc 100644 --- a/src/main/java/com/booleanuk/extension/Extension.java +++ b/src/main/java/com/booleanuk/extension/Extension.java @@ -25,6 +25,47 @@ public class Extension extends ExtensionBase { E.g. multiply(["2", "7", "3"], 3) -> [6, 21, 9] */ + public float add(float one, float two) { + return one + two; + } + public double add(double one, double two) { + return one + two; + } -} + public float subtract(float one, float two) { + return one - two; + } + + public String subtract(String str, char letter) { + String newStr = ""; + for(int i = 0; i < str.length(); i++) { + if(str.charAt(i) != letter) { + newStr += str.charAt(i); + } + } + return newStr; + } + + public int multiply(int one, int two) { + return one * two; + } + + public String multiply(String str, int num) { + String newStr = ""; + for(int i = 0; i < num; i++) { + newStr += str; + if(i != num - 1) + newStr += ","; + } + return newStr; + } + + public int[] multiply(String[] num, int acc) { + int[] newNums = new int[num.length]; + for(int i = 0; i < num.length; i++) { + newNums[i] = Integer.parseInt(num[i]) * acc; + } + return newNums; + } +} \ No newline at end of file