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 @@ -2,40 +2,85 @@


public class NumberUtilities {

public static String getExponentiations(int start, int stop, int step, int exponent) {
String result = "";
for (int i = start; i < stop; i += step) {
int outcome = (int)Math.pow(i, exponent);
result = result + outcome;

public static String getExponentiations(int start, int stop, int step, int exponent) {
return null;
}
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 = result + i;
System.out.println(result);
}
return result;
}

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

}
return result; // getRange(start, stop, step;1));
}

public static String getRange(int stop) {
return null;
String result = "";
for (int i = 0; i < stop; i++) {
result = result + i;
}
return result; // getRange(start:0, stop, step:1);
}

/*
* 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 (i % 2 == 0) {
result += i;
}

}
return result;
}

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

for (int i = start; i < stop; i++) {
if (i % 2 != 0) {
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 = result + (i * i);


}
return result;
}

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

public class TableUtilities {
public static String getMultiplicationTable(int tableSize) {
return null;
String result = "";
for (int i = 1; i <= tableSize; i++) { // Loop for the row, i = row
for (int j = 1; j <= tableSize; j++) { // Loop for column, j = column
result += String.format("%3d |", i * j); // %d means print number. 3 notes the amount of space
}
result += "\n"; //new line after each row
}
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,31 @@
public class TriangleUtilities {

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

public static String getTriangle(int numberOfRows) {
return null;
String result = "";
int i = 1;
while (i < numberOfRows) {
result = result + getRow(i) + "\n";
i++;
}
return result;
}

// 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,7 @@ public void testGetRange3C() {
@Test
public void testGetEvenNumbers() {
// : Given
String expected = "5791113151719";
String expected = "681012141618"; //681012141618
int start = 5;
int stop = 20;

Expand All @@ -198,7 +198,7 @@ public void testGetEvenNumbers() {
@Test
public void testGetOddNumbers() {
// : Given
String expected = "681012141618";
String expected = "5791113151719"; //5791113151719
int start = 5;
int stop = 20;
int step = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public void getRow() {
String actual = TriangleUtilities.getRow(width);
Assert.assertEquals(expected, actual);
}

@Test
public void getRow3() {
String expected = "***";
int width = 3;
String actual = TriangleUtilities.getRow(width);
Assert.assertEquals(expected, actual);
}

@Test
public void getRow5() {
String expected = "*****";
int width = 5;
Expand Down