diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 7987028..33de2bd 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -51,12 +51,19 @@ 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 numOne, int numTwo){ + return numOne+numTwo; + } @@ -64,7 +71,8 @@ public Exercise(int age) { 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 strOne, String strTwo){ + return strOne + " " + strTwo; + } } diff --git a/src/main/java/com/booleanuk/extension/Extension.java b/src/main/java/com/booleanuk/extension/Extension.java index 62b878f..c93cb2d 100644 --- a/src/main/java/com/booleanuk/extension/Extension.java +++ b/src/main/java/com/booleanuk/extension/Extension.java @@ -25,6 +25,42 @@ public class Extension extends ExtensionBase { E.g. multiply(["2", "7", "3"], 3) -> [6, 21, 9] */ + public float add(float flOne, float flTwo){ + return flOne + flTwo; + } + public double add(double dblOne, double dblTwo){ + return dblOne + dblTwo; + } + public float subtract(float flOne, float flTwo){ + return flOne - flTwo; + } + + public String subtract(String str, char ch){ + return str.replace(Character.toString(ch), ""); + } + + public int multiply(int numOne, int numTwo){ + return numOne * numTwo; + } + + public String multiply(String str, int num){ + String sequence = str; + for (int i = 1; i