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
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,77 @@
public class NumberUtilities {

public static String getExponentiations(int start, int stop, int step, int exponent) {
return null;
String result = "";

for(int i = start; i < stop; i+=step){
result+=(int)(Math.pow(i, exponent));
}
return result;
}

public static String getRange(int start, int stop, int step) {
return null;
String result = "";

for(int i = start ; i < stop; i+=step){
result+= i;
}
return result;
}

public static String getRange(int start, int stop) {
return null;
String result = "";

for(int i = start ; i < stop; i++){
result+= i;
}
return result;
}

public static String getRange(int stop) {
return null;
String result = "";

for(int i = 0 ; i < stop; i++){
result+= i;
}
return result;
}

/*
* natural break
*/

public static boolean isNumberEven(int toTest) { return false; }
public static boolean isNumberOdd(int toTest) { return false; }
public static boolean isNumberEven(int toTest) { return toTest%2==0; }
public static boolean isNumberOdd(int toTest) { return toTest%2!=0; }

public static String getEvenNumbers(int start, int stop) {
return null;
String result = "";

for(int i = start ; i < stop; i++){
if(isNumberEven(i))
result+=i;
}
return result;

}

public static String getOddNumbers(int start, int stop) {
return null;
String result = "";

for(int i = start ; i < stop; i++){
if(isNumberOdd(i))
result+=i;
}
return result;

}

public static String getSquareNumbers(int start, int stop, int step) {
return null;
String result = "";

for(int i = start ; i < stop; i+=step){
result+=i*i;
}
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@

public class TableUtilities {
public static String getMultiplicationTable(int tableSize) {
return null;

String result = "";

for (int i = 1; i < tableSize + 1; i++) {
for (int y = 1; y < tableSize + 1; y++) {
int temp = i*y;
if(temp<10)
result+=" "+temp+" |";
else if (temp<100)
result+=" "+temp+" |";
else
result+=""+temp+" |";
}
result+="\n";
}

return result;
}

public static String getSmallMultiplicationTable() {
return null;
return getMultiplicationTable(5);
}

public static String getLargeMultiplicationTable() {
return null;
return getMultiplicationTable(10);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@
public class TriangleUtilities {

public static String getRow(int numberOfStars) {
return null;
String result = "";
for(int i = 1; i <= numberOfStars; i++){
result +='*';
}


return result;
}

public static String getTriangle(int numberOfRows) {
return null;

String temp = "";

for (int i = 1; i < numberOfRows;i++){
temp+= getRow(i)+'\n';
}
return temp;
}

// hmm

public static String getSmallTriangle() {
return null;
return getTriangle(5);
}

public static String getLargeTriangle() {
return null;
return getTriangle(10);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ public void testGetRange3C() {
@Test
public void testGetEvenNumbers() {
// : Given
String expected = "5791113151719";

String expected = "681012141618";
int start = 5;
int stop = 20;

Expand All @@ -198,7 +199,7 @@ public void testGetEvenNumbers() {
@Test
public void testGetOddNumbers() {
// : Given
String expected = "681012141618";
String expected = "5791113151719";
int start = 5;
int stop = 20;
int step = 5;
Expand Down