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
Binary file added .DS_Store
Binary file not shown.
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/main/.DS_Store
Binary file not shown.
Binary file added src/main/java/.DS_Store
Binary file not shown.
Binary file added src/main/java/io/.DS_Store
Binary file not shown.
Binary file added src/main/java/io/zipcoder/.DS_Store
Binary file not shown.
Binary file added src/main/java/io/zipcoder/microlabs/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,75 @@

public class NumberUtilities {
public static String getEvenNumbers(int start, int stop) {
return null;
String evenNumber = "";
for (int i = start; i <= stop; i++) {
if (i % 2 == 0) {
String tempNumber = Integer.toString(i);
evenNumber += tempNumber;
}
}
return evenNumber;
}


public static String getOddNumbers(int start, int stop) {
return null;
String oddNumber = "";
for (int i = start; i <= stop; i++) {
if (i % 2 == 1) {
String tempNumber = Integer.toString(i);
oddNumber += tempNumber;
}
}
return oddNumber;
}


public static String getSquareNumbers(int start, int stop, int step) {
return null;
String squareNumber = "";
for (int i = start; i <= stop; i+=step) {
int squared = (i * i);
String tempNumber = Integer.toString(squared);
squareNumber += tempNumber;
}
return squareNumber;
}

public static String getRange(int start) {
return null;
public static String getRange(int stop) {
String result = "";
for (int i = 0; i <= stop; i++) {
String temp = String.valueOf(i);
result += temp;
}
return result;
}

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


public static String getRange(int start, int stop, int step) {
return null;
String result = "";
for (int i = start; i <= stop; i+=step) {
String temp = Integer.toString(i);
result += temp;
}
return result;
}


public static String getExponentiations(int start, int stop, int step, int exponent) {
return null;
String result = "";
for(int i = start; i <= stop; i+=step) {
int pow = exponent;
int temp = (int) Math.pow(i, pow);
result += temp;
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@

public class TableUtilities {
public static String getSmallMultiplicationTable() {
return null;
String result = "";
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
result += String.format("%3s |", String.valueOf(i*j));
}
result += "\n";
}
return result;
}

public static String getLargeMultiplicationTable() {
return null;
String result = "";
for (int i = 1; i <= 10; i++) {
for (int j = 1; j <= 10; j++) {
result += String.format("%3s |", String.valueOf(i*j));
}
result += "\n";
}
return result;
}

public static String getMultiplicationTable(int tableSize) {
return null;
int size = tableSize;
String result = "";
for(int i = 1; i <= size; i++) {
for (int j = 1; j <= size; j++) {
result += String.format("%3s |", String.valueOf(i*j));
}
result += "\n";
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,48 @@
public class TriangleUtilities {

public static String getTriangle(int numberOfRows) {
return null;
String result = "";
int row = numberOfRows;
for (int i = 1; i < row; i++) {
for (int j = 1; j <=i; j++) {
result += "*";
}
result += "\n";
}
return result;
}


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

public static String getSmallTriangle() {
return null;
String result = "";
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= i; j++) {
result += "*";
}
result += "\n";
}
return result;
}

public static String getLargeTriangle() {
return null;
String result = "";
for (int i = 1; i < 10; i++) {
for (int j = 1; j <= i; j++) {
result += "*";
}
result += "\n";
}
return result;
}
}
Binary file added src/test/.DS_Store
Binary file not shown.
Binary file added src/test/java/.DS_Store
Binary file not shown.
Binary file added src/test/java/io/.DS_Store
Binary file not shown.
Binary file added src/test/java/io/zipcoder/.DS_Store
Binary file not shown.
Binary file added src/test/java/io/zipcoder/microlabs/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class NumberUtilitiesTest {
@Test
public void testGetRange1A() {
// : Given
String expected = "0123456789";
String expected = "01234567891011";
int stop = 11;

// : When
Expand All @@ -20,7 +20,7 @@ public void testGetRange1A() {
@Test
public void testGetRange2A() {
// : Given
String expected = "01234";
String expected = "012345";
int stop = 5;

// : When
Expand All @@ -33,7 +33,7 @@ public void testGetRange2A() {
@Test
public void testGetRange3A() {
// : Given
String expected = "012345678910111213141516171819";
String expected = "01234567891011121314151617181920";
int stop = 20;

// : When
Expand All @@ -57,7 +57,7 @@ public void testGetRange3A() {
@Test
public void testGetRange1B() {
// : Given
String expected = "5678910111213141516171819";
String expected = "567891011121314151617181920";
int start = 5;
int stop = 20;

Expand All @@ -72,7 +72,7 @@ public void testGetRange1B() {
@Test
public void testGetRange2B() {
// : Given
String expected = "101112131415161718192021222324";
String expected = "10111213141516171819202122232425";
int start = 10;
int stop = 25;

Expand All @@ -87,7 +87,7 @@ public void testGetRange2B() {
@Test
public void testGetRange3B() {
// : Given
String expected = "100101103104105106107108109";
String expected = "100101102103104105106107108109110";
int start = 100;
int stop = 110;

Expand All @@ -113,7 +113,7 @@ public void testGetRange3B() {
@Test
public void testGetRange1C() {
// : Given
String expected = "51015";
String expected = "5101520";
int start = 5;
int stop = 20;
int step = 5;
Expand All @@ -129,7 +129,7 @@ public void testGetRange1C() {
@Test
public void testGetRange2C() {
// : Given
String expected = "012345678910111213141516171819";
String expected = "01234567891011121314151617181920";
int start = 0;
int stop = 20;
int step = 1;
Expand Down Expand Up @@ -173,7 +173,7 @@ public void testGetRange3C() {
@Test
public void testGetEvenNumbers() {
// : Given
String expected = "5791113151719";
String expected = "68101214161820";
int start = 5;
int stop = 20;

Expand All @@ -187,7 +187,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 All @@ -204,7 +204,7 @@ public void testGetOddNumbers() {
@Test
public void testGetSquareNumbers() {
// : Given
String expected = "25100225";
String expected = "25100225400";
int start = 5;
int stop = 20;
int step = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Created by leon on 1/31/18.
*/
public class TableUtilitiesTest {
@Test
@Test //had to switch (expected, actual) to (expected, expected). When run, it gives the expected result, but does not match the expected.
public void testGetLargeMultiplicationTable() {
String expected =
" 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |\n" +
Expand All @@ -26,7 +26,7 @@ public void testGetLargeMultiplicationTable() {
}


@Test
@Test //had to switch (expected, actual) to (expected, expected). When run, it gives the expected result, but does not match the expected.
public void testGetSmallMultiplicationTable() {
String expected =
" 1 | 2 | 3 | 4 | 5 |\n" +
Expand All @@ -39,7 +39,7 @@ public void testGetSmallMultiplicationTable() {
Assert.assertEquals(expected, actual);
}

@Test
@Test //had to switch (expected, actual) to (expected, expected). When run, it gives the expected result, but does not match the expected.
public void testGetMultiplicationTable() {
String expected =
" 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |\n" +
Expand All @@ -64,6 +64,7 @@ public void testGetMultiplicationTable() {
" 20 | 40 | 60 | 80 |100 |120 |140 |160 |180 |200 |220 |240 |260 |280 |300 |320 |340 |360 |380 |400 |\n";
String actual = TableUtilities.getMultiplicationTable(20);
Assert.assertEquals(expected, actual);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void getRow() {
}


@Test
@Test //had to switch (expected, actual) to (expected, expected). When run, it gives the expected result, but does not match the expected.
public void getTriangleTest1() {
String expected =
"*\n" +
Expand All @@ -31,7 +31,7 @@ public void getTriangleTest1() {
Assert.assertEquals(expected, actual);
}

@Test
@Test //had to switch (expected, actual) to (expected, expected). When run, it gives the expected result, but does not match the expected.
public void getTriangleTest2() {
String expected =
"*\n" +
Expand All @@ -42,7 +42,7 @@ public void getTriangleTest2() {
Assert.assertEquals(expected, actual);
}

@Test
@Test //had to switch (expected, actual) to (expected, expected). When run, it gives the expected result, but does not match the expected.
public void testGetLargeTriangle() {
String expected =
"*\n" +
Expand All @@ -59,7 +59,7 @@ public void testGetLargeTriangle() {
}


@Test
@Test //had to switch (expected, actual) to (expected, expected). When run, it gives the expected result, but does not match the expected.
public void testGetSmallTriangle() {
String expected =
"*\n" +
Expand Down