Skip to content
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

Tri Guys #51

Open
wants to merge 1 commit 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 @@ -3,26 +3,56 @@

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


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


public static String getSquareNumbers(int start, int stop, int step) {
return null;
}
StringBuilder squareString = new StringBuilder();

for (int i = start; i < stop; i++){
squareString.append(i*i);
}
return squareString.toString();
}




public static String getRange(int start, int stop, int step) {
return null;
}
StringBuilder range = new StringBuilder();

for (int i = start; i<stop; i++) {
range.append(i);
} return range.toString();
}
// must add to.String to range bc you made a string builder

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

StringBuilder exponentString = new StringBuilder();

for (int i = start; i < stop-1; i += step){
exponentString.append(Math.pow(i,exponent));
}
return exponentString.toString();

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

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

StringBuilder tableOne = new StringBuilder();

for (int a = 1; a <= 5; a++){
for (int b = 1; b <= 5; b++){
int product = a * b;
tableOne.append(String.format("%3d |", product));
}
tableOne.append("\n");

}
return tableOne.toString();
}


public static String getLargeMultiplicationTable() {
return null;

StringBuilder tableOne = new StringBuilder();

for (int a = 1; a <= 10; a++){
for (int b = 1; b <= 10; b++){
int product = a * b;
tableOne.append(String.format("%3d |", product));
}
tableOne.append("\n");

}
return tableOne.toString();
}

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

StringBuilder tableOne = new StringBuilder();

for (int a = 1; a <= tableSize; a++){
for (int b = 1; b <= tableSize; b++){
int product = a * b;
tableOne.append(String.format("%3d |", product));
}
tableOne.append("\n");

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

public static String getTriangle(int numberOfRows) {
return null;
System.out.println("Get Triangle");
String resultString = "";
System.out.println(resultString);
for (int i = 1; i < numberOfRows; i++){

String rowofStars = "";
for (int j = 0; j < i; j++){
rowofStars = rowofStars + "*";

}
resultString = resultString + rowofStars + "\n";
}

return resultString;
}

public static String getRow(int numberOfStars) {
return null;
System.out.println("Get Row");
String resultString = "";
for (int i = 0; i < numberOfStars; i++){
resultString = resultString + "*";
}
return resultString;
}

public static String getSmallTriangle() {
return null;
System.out.println("Get Small Triangle");
String resultString = "";
System.out.println(resultString);
for (int i = 1; i < 5; i++){
String rowofStars = "";
for (int j = 0; j < i; j++){
rowofStars = rowofStars + "*";

}
resultString = resultString + rowofStars + "\n";
}

return resultString;
}

public static String getLargeTriangle() {
return null;
System.out.println("Get Large Triangle");
String resultString = "";
System.out.println(resultString);
for (int i = 1; i < 10; i++){
String rowofStars = "";
for (int j = 0; j < i; j++){
rowofStars = rowofStars + "*";

}
resultString = resultString + rowofStars + "\n";
}

return resultString;
}
}
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,7 +65,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