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
25 changes: 20 additions & 5 deletions src/main/java/com/booleanuk/core/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.booleanuk.helpers.ExerciseBase;

import java.util.ArrayList;

public class Exercise extends ExerciseBase {
/*
A method is a function, a single piece of logic that can run. In Java, a class is a convenient
Expand Down Expand Up @@ -35,7 +37,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 +50,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,7 +67,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 <= (upper - lower); i++) {
array[i] = lower + i;
}
return array;
}


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

public String shout(String input, int num) {
StringBuilder sb = new StringBuilder();
sb.append( input.toUpperCase());
for (int i = 0; i < num; i++) {
sb.append( "!");
}
return sb.toString();
}



Expand Down
14 changes: 10 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,7 @@ 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 +20,9 @@ public class Extension extends ExtensionBase {
and the result of calling the bakingTime method
*/


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


/*
Expand All @@ -30,7 +32,9 @@ public class Extension extends ExtensionBase {
It must return how many minutes it will take to prepare the cake based on
each layer taking 3 minutes to prepare
*/

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



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


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


}
Loading