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
23 changes: 17 additions & 6 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;
}

/*
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 @@ -66,7 +66,13 @@ public String happilyGreet() {
*/



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

/*
4. Shout at a dev
Expand All @@ -81,7 +87,12 @@ The method must return the same string in upper case with exclamation marks (!)
error, 10 | ERROR!!!!!!!!!!
*/



public String shout(String message, int x) {
StringBuilder exclamations = new StringBuilder();
for (int i = 0; i < x; i++) {
exclamations.append("!");
}
return message.toUpperCase().concat(exclamations.toString());
}

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

public int bakingTime() {
return 50;
}



Expand All @@ -20,7 +22,9 @@ public class Extension extends ExtensionBase {
and the result of calling the bakingTime method
*/


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


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


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


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


public int totalTimeSpent(int numOfLayers, int minutesInOven) {
return calculatePrepTime(numOfLayers) + minutesInOven;
}


}
Loading