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
21 changes: 18 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,7 @@ 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;
return number + 1;
}

/*
Expand All @@ -48,8 +48,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 @@ -65,6 +65,13 @@ public String happilyGreet() {
-1, 1 | [-1,0,1]
*/

public int [] constructNumberArray(int lower, int upper) {
int [] array = new int [upper - lower + 1];
for (int i = 0; i < array.length; i++) {
array[i] = lower + i;
}
return array;
}



Expand All @@ -81,7 +88,15 @@ The method must return the same string in upper case with exclamation marks (!)
error, 10 | ERROR!!!!!!!!!!
*/

public String shout(String word, int number) {
StringBuilder exclamation = new StringBuilder();
for(int i = 0; i < number; i++) {
exclamation.append("!");
}
word += exclamation;

return word.toUpperCase();
}


}
16 changes: 13 additions & 3 deletions src/main/java/com/booleanuk/extension/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ public class Extension extends ExtensionBase {
*/



public int bakingTime() {
return 50;
}

/*
6. Create a method named remainingBakeTime that accepts one input:
Expand All @@ -21,7 +23,9 @@ public class Extension extends ExtensionBase {
*/



public int remainingBakeTime(int inOven) {
return bakingTime() - inOven;
}

/*
7. Create a method named calculatePrepTime that accepts one input:
Expand All @@ -31,6 +35,9 @@ public class Extension extends ExtensionBase {
each layer taking 3 minutes to prepare
*/

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



Expand All @@ -44,7 +51,10 @@ public class Extension extends ExtensionBase {
in the oven. Use your calculatePrepTime method in the calculation
*/


public int totalTimeSpent(int layers, int numberOfMinInOven) {
int sum = calculatePrepTime(layers) + bakingTime() - remainingBakeTime(numberOfMinInOven);
return sum;
}


}