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

completed lab #46

Open
wants to merge 2 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
63 changes: 54 additions & 9 deletions NumberUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,74 @@
public class NumberUtilities {

public static String getRange(int stop) {
return null;
int i;
String nums = "";
for (i=0; i<stop; i++){
nums = nums + Integer.toString(i);

}
return nums;
}

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

}
return nums;
}


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

nums = nums + Integer.toString(i);

}
return nums;
}

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

}
return nums;
}


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

}
return nums;


}


public static String getExponentiations(int start, int stop, int exponent) {
return null;
int i;
String nums = "";
for (i=start; i<=stop; i++){
Math.pow(i, exponent);
nums = nums + Integer.toString((int)Math.pow(i, exponent));
}


return nums;
}
}
}

57 changes: 52 additions & 5 deletions TableUtilities.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,62 @@


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

for(int i = 1; i<=8; i++){
for(int j = 1; j<=5; j++) {
if (j*i < 10) {
table = table + ((" " + (j * i)) + " |");
} else {
table = table + ((" " + (j * i)) + " |");;
}

}
table = table + "\n";
}
return table;
}



public static String getLargeMultiplicationTable() {
return null;
}
String table = "";

for(int i = 1; i<=10; i++){
for(int j = 1; j<=10; j++) {
if (j*i < 10) {
table = table + ((" " + (j * i)) + " |");
} else if(j*i < 100){
table = table + ((" " + (j * i)) + " |");
} else {
table = table + (("" + (j * i)) + " |");
}

}

table = table + "\n";
}
return table;
}

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

for(int i = 1; i<=tableSize; i++){
for(int j = 1; j<=tableSize; j++) {
if (j*i < 10) {
table = table + ((" " + (j * i)) + " |");
} else if(j*i < 100){
table = table + ((" " + (j * i)) + " |");
} else {
table = table + (("" + (j * i)) + " |");
}

}

table = table + "\n";
}
return table;
}
}
2 changes: 1 addition & 1 deletion TableUtilitiesTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


import org.junit.Assert;
import org.junit.Test;
Expand Down
37 changes: 33 additions & 4 deletions TriangleUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,48 @@
public class TriangleUtilities {

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

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

for(int i = 1; i<=numberOfRows; i++){
for(int j = 1; j<=i; j++) {
stars = stars + "*";
}
stars = stars + "\n";
}
return stars;

}


public static String getSmallTriangle() {
return null;
String stars = "";

for(int i = 1; i<=4; i++){
for(int j = 1; j<=i; j++) {
stars = stars + "*";
}
stars = stars + "\n";
}
return stars;
}

public static String getLargeTriangle() {
return null;
String stars = "";

for(int i = 1; i<=9; i++){
for(int j = 1; j<=i; j++) {
stars = stars + "*";
}
stars = stars + "\n";
}
return stars;
}
}
140 changes: 82 additions & 58 deletions package.bluej
Original file line number Diff line number Diff line change
@@ -1,79 +1,103 @@
#BlueJ package file
dependency1.from=NumberUtilitiesTest
dependency1.to=NumberUtilities
dependency1.from=TriangleUtilitiesTest
dependency1.to=TriangleUtilities
dependency1.type=UsesDependency
dependency2.from=TriangleUtilitiesTest
dependency2.to=TriangleUtilities
dependency2.from=NumberUtilitiesTest
dependency2.to=NumberUtilities
dependency2.type=UsesDependency
dependency3.from=TableUtilitiesTest
dependency3.to=TableUtilities
dependency3.type=UsesDependency
editor.fx.0.height=722
editor.fx.0.width=800
editor.fx.0.x=537
editor.fx.0.y=28
objectbench.height=164
objectbench.width=484
editor.fx.0.height=0
editor.fx.0.width=0
editor.fx.0.x=0
editor.fx.0.y=0
objectbench.height=163
objectbench.width=893
package.divider.horizontal=0.6
package.divider.vertical=0.7560627674750356
package.editor.height=523
package.editor.width=382
package.editor.x=20
package.editor.y=57
package.frame.height=759
package.frame.width=508
package.divider.vertical=0.734375
package.editor.height=463
package.editor.width=800
package.editor.x=16
package.editor.y=25
package.frame.height=704
package.frame.width=917
package.numDependencies=3
package.numTargets=6
package.numTargets=10
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.height=58
readme.height=60
readme.name=@README
readme.width=47
readme.width=48
readme.x=10
readme.y=10
target1.height=50
target1.name=TableUtilitiesTest
target1.showInterface=false
target1.type=UnitTestTargetJunit4
target1.width=110
target1.x=100
target1.y=270
target1.height=70
target1.name=README-TriangleUtilities.md
target1.type=TextTarget
target1.width=180
target1.x=320
target1.y=150
target10.association=TriangleUtilitiesTest
target10.height=50
target10.name=TriangleUtilities
target10.showInterface=false
target10.type=ClassTarget
target10.width=120
target10.x=560
target10.y=170
target2.height=50
target2.name=TriangleUtilitiesTest
target2.name=TableUtilitiesTest
target2.showInterface=false
target2.type=UnitTestTargetJunit4
target2.width=120
target2.x=100
target2.y=160
target3.association=TableUtilitiesTest
target2.width=110
target2.x=600
target2.y=270
target3.height=50
target3.name=TableUtilities
target3.name=TriangleUtilitiesTest
target3.showInterface=false
target3.type=ClassTarget
target3.width=110
target3.x=70
target3.y=300
target4.association=NumberUtilitiesTest
target4.height=50
target4.name=NumberUtilities
target4.showInterface=false
target4.type=ClassTarget
target4.width=120
target4.x=80
target4.y=70
target3.type=UnitTestTargetJunit4
target3.width=120
target3.x=590
target3.y=140
target4.height=70
target4.name=README-TableUtilities.md
target4.type=TextTarget
target4.width=170
target4.x=330
target4.y=280
target5.association=TableUtilitiesTest
target5.height=50
target5.name=NumberUtilitiesTest
target5.name=TableUtilities
target5.showInterface=false
target5.type=UnitTestTargetJunit4
target5.width=120
target5.x=110
target5.y=40
target6.association=TriangleUtilitiesTest
target6.height=50
target6.name=TriangleUtilities
target6.showInterface=false
target6.type=ClassTarget
target6.width=120
target6.x=70
target6.y=190
target5.type=ClassTarget
target5.width=110
target5.x=570
target5.y=300
target6.height=70
target6.name=README-NumberUtilities.md
target6.type=TextTarget
target6.width=180
target6.x=310
target6.y=20
target7.association=NumberUtilitiesTest
target7.height=50
target7.name=NumberUtilities
target7.showInterface=false
target7.type=ClassTarget
target7.width=120
target7.x=570
target7.y=50
target8.height=70
target8.name=README.md
target8.type=TextTarget
target8.width=120
target8.x=70
target8.y=70
target9.height=50
target9.name=NumberUtilitiesTest
target9.showInterface=false
target9.type=UnitTestTargetJunit4
target9.width=120
target9.x=600
target9.y=20