File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
src/main/java/com/booleanuk/core Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ public class Exercise extends ExerciseBase {
1717
1818 The above assumes that the MyClass class has a constructor that defines a single parameter: a String.
1919 */
20+
21+
2022 public Exercise (String name ) {
2123 // A constructor must always be named exactly the same as the class name. This is the constructor for the
2224 // Exercise class, which accepts one string parameter.
@@ -51,20 +53,28 @@ public Exercise(int age) {
5153 Create a constructor that accepts both a String and an int as parameters, in that order, and assign the values
5254 provided to the name and age members
5355 */
56+ public Exercise (String name , int age ){
57+ this .age = age ;
58+ this .name = name ;
59+ }
5460
5561
5662
5763 /*
5864 2. Create a method named add that accepts two integers. The method should return the numbers added together.
5965 */
60-
66+ public int add (int num1 , int num2 ) {
67+ return num1 +num2 ;
68+ }
6169
6270
6371 /*
6472 3. Create another method named add that accepts two Strings. The method should return the strings concatenated
6573 together with a space in between.
6674 */
67-
75+ public String add (String s1 , String s2 ){
76+ return s1 +" " +s2 ;
77+ }
6878
6979
7080}
You can’t perform that action at this time.
0 commit comments