Skip to content
Open
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
22 changes: 19 additions & 3 deletions src/main/java/com/booleanuk/core/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public String greet(String name) {
Complete this method so that it increases the number given by 1 and returns the result
*/
public int increment(int number) {
return 0;
number++;
return number;
}

/*
Expand All @@ -48,8 +49,8 @@ public int increment(int number) {
Nathan | Hi, Nathan :)
Edward | Hi, Edward :)
*/
public String happilyGreet() {
return "Not implemented yet";
public String happilyGreet(String name) {
return "Hi, " + name + " :)";
}

/*
Expand All @@ -64,6 +65,17 @@ public String happilyGreet() {
10, 13 | [10,11,12,13]
-1, 1 | [-1,0,1]
*/
public int[] constructNumberArray(int lower, int upper) {
int size = upper - lower + 1;
int[] nums = new int[size];

int index = 0;
for (int n = lower; n <= upper; n++) {
nums[index++] = n;
}

return nums;
}



Expand All @@ -80,6 +92,10 @@ The method must return the same string in upper case with exclamation marks (!)
disaster, 5 | DISASTER!!!!!
error, 10 | ERROR!!!!!!!!!!
*/
public String shout(String s, int n) {
String result = s.toUpperCase();
return result + new String("!").repeat(n);
}



Expand Down
15 changes: 12 additions & 3 deletions src/main/java/com/booleanuk/extension/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public class Extension extends ExtensionBase {
5. Create a method named bakingTime that returns the number 50
*/

public int bakingTime() {
return 50;
}



Expand All @@ -19,6 +22,9 @@ public class Extension extends ExtensionBase {
It must return how many minutes are left to bake based on the input
and the result of calling the bakingTime method
*/
public int remainingBakeTime(int minutes) {
return bakingTime() - minutes;
}



Expand All @@ -31,6 +37,9 @@ public class Extension extends ExtensionBase {
each layer taking 3 minutes to prepare
*/

public int calculatePrepTime(int layers) {
return 3 * layers;
}



Expand All @@ -43,8 +52,8 @@ public class Extension extends ExtensionBase {
which is the sum of the preparation time and the number of minutes it's been
in the oven. Use your calculatePrepTime method in the calculation
*/



public int totalTimeSpent(int layers, int minutesPassed) {
return calculatePrepTime(layers) + minutesPassed;
}

}
Loading