Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/com/booleanuk/core/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,31 @@ public Exercise(int age) {
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;
}



/*
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 numOne, String numTwo){

return numOne + " " + numTwo;
}


}
32 changes: 31 additions & 1 deletion src/main/java/com/booleanuk/extension/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Extension extends ExtensionBase {

1. add, which accepts two floats and returns a float (both floats added together)


2. add, which accepts two doubles and returns a double (both doubles added together)

3. subtract, which accepts two floats and returns a float (first float minus second float)
Expand All @@ -26,5 +27,34 @@ public class Extension extends ExtensionBase {
multiply(["2", "7", "3"], 3) -> [6, 21, 9]
*/


// 1)

public float add(float numOne, float numTwo){
return numOne + numTwo;
}

// 2)
public double add(double numOne, double numTwo){
return numOne + numTwo;
}
// 3)
public float subtract(float numOne, float numTwo){
return numOne - numTwo;
}
// 4)
public String subtract(String word, char letter){
String answer = "";

return answer;
}

public int multiply(int a, int b) {
return a*b;
}

public String multiply(String word, int amount) {
StringBuilder answer = new StringBuilder();
answer.append("word".repeat(Math.max(0, amount)));
return word;
}
}
Loading