Skip to content

final. thanks. #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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,27 +2,57 @@


public class NumberUtilities {

public static String getEvenNumbers(int start, int stop) {
return null;
StringBuilder evens = new StringBuilder();
for (int i = start; i <stop; i++) {
if (i % 2 == 0) {
evens.append(i);
}
}

return evens.toString();
}


public static String getOddNumbers(int start, int stop) {
return null;
StringBuilder odds = new StringBuilder();
for (int i = start; i <stop; i++) {
if (i % 2 == 1) {
odds.append(i);
}
}

return odds.toString();
}


public static String getSquareNumbers(int start, int stop, int step) {
return null;
StringBuilder getSquares = new StringBuilder();
for (int i = start; i < stop; i+=step){
getSquares.append((int) Math.pow(i,2));
}

return getSquares.toString();
}


public static String getRange(int start, int stop, int step) {
return null;
StringBuilder myRange = new StringBuilder();
for (int i = start; i < stop; i+=step){
myRange.append(i);
}

return myRange.toString();
}


public static String getExponentiations(int start, int stop, int step, int exponent) {
return null;
StringBuilder myExponents = new StringBuilder();
for (int i = start; i<stop; i+=step){
myExponents.append((int) Math.pow(i,exponent));
}

return myExponents.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,47 @@

public class TableUtilities {
public static String getSmallMultiplicationTable() {
return null;
String myTable = "";

for (int row =1; row <=5; row++){
for (int col=1; col<=5; col++){

int checkSpace = col*row;
if (checkSpace < 10) {
myTable += " " + checkSpace + " | ";
} else if (checkSpace >= 10){
myTable += " " + checkSpace + " | ";
}

}
myTable += "\n";
}

return myTable;
}

public static String getLargeMultiplicationTable() {
return null;
StringBuilder getLarge = new StringBuilder();
for (int row=1; row <11 ; row++){
for (int col=1; col<11; col++){
getLarge.append(col*row + " | ");
}
getLarge.append("\n");

}

return getLarge.toString();
}

public static String getMultiplicationTable(int tableSize) {
return null;
StringBuilder getMult = new StringBuilder();
for (int row = 1; row <= tableSize; row++){
for (int col = 1; col <= tableSize; col++){
getMult.append(row * col + " | ");
}
getMult.append("\n");
}

return getMult.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,49 @@
public class TriangleUtilities {

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

StringBuilder myTri = new StringBuilder();
for (int i = 1; i < numberOfRows; i++) {
for (int j = 0; j < i; j++) {
myTri.append("*");
}
myTri.append("\n");
}

return myTri.toString();
}

public static String getRow(int numberOfStars) {
return null;
StringBuilder newRow = new StringBuilder();
for (int i = 0; i < numberOfStars; i++){
newRow.append("*");
}
return newRow.toString();
}

public static String getSmallTriangle() {
return null;
StringBuilder smallTri = new StringBuilder();
for (int i = 1; i < 5; i++) {
for (int j = 0; j < i; j++) {
smallTri.append("*");
}
smallTri.append("\n");
}

return smallTri.toString();
}

public static String getLargeTriangle() {
return null;

StringBuilder largeTri = new StringBuilder();
for (int i = 1; i < 10; i++) {
for (int j = 0; j < i; j++) {
largeTri.append("*");
}
largeTri.append("\n");
}

return largeTri.toString();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void testGetRange2() {
@Test
public void testGetEvenNumbers() {
// : Given
String expected = "5791113151719";
String expected = "681012141618";
int start = 5;
int stop = 20;

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


// : When
String actual = NumberUtilities.getOddNumbers(start, stop);
Expand Down