diff --git a/NumberUtilities.java b/NumberUtilities.java index 1d5ba50..cdad7ba 100644 --- a/NumberUtilities.java +++ b/NumberUtilities.java @@ -1,32 +1,84 @@ - - - public class NumberUtilities { public static String getRange(int stop) { - return null; + String outcome = ""; + String convert; + + for (int i = 0; i < stop; i++) { + convert = Integer.toString(i); + outcome += convert; + } + + return outcome; } public static String getRange(int start, int stop) { - return null; + String outcome = ""; + String convert; + + for (int i = start; i < stop; i++) { + convert = Integer.toString(i); + outcome += convert; + } + + return outcome; } public static String getRange(int start, int stop, int step) { - return null; + String outcome = ""; + String convert; + + for (int i = start; i < stop;) { + convert = Integer.toString(i); + outcome += convert; + i += step; + } + + return outcome; } public static String getEvenNumbers(int start, int stop) { - return null; + String outcome = ""; + String convert; + + for (int i = start; i < stop; i++) { + if (i % 2 == 0) { + convert = Integer.toString(i); + outcome += convert; + } + } + + return outcome; } public static String getOddNumbers(int start, int stop) { - return null; + String outcome = ""; + String convert; + + for (int i = start; i < stop; i++) { + if (i % 2 != 0) { + convert = Integer.toString(i); + outcome += convert; + } + } + + return outcome; } public static String getExponentiations(int start, int stop, int exponent) { - return null; + String outcome = ""; + String convert; + int exponentials; + + for (int i = start; i <= stop; i++) { + exponentials = (int)Math.pow(i, exponent); + convert = Integer.toString(exponentials); + outcome += convert; + } + + return outcome; } -} +} \ No newline at end of file diff --git a/TableUtilities.java b/TableUtilities.java index 03bf004..e2eef53 100644 --- a/TableUtilities.java +++ b/TableUtilities.java @@ -1,15 +1,100 @@ - - -public class TableUtilities { + public class TableUtilities { public static String getSmallMultiplicationTable() { - return null; + String outcome = ""; + String convert; + int multiple; + + for (int i = 1; i <= 5; i++) { + for (int j = 1; j <= 5; j++) { + multiple = i * j; + convert = Integer.toString(multiple); + + if (multiple >= 10) { + if (j == 5) { + outcome += " " + convert + " |\n"; + } else { + outcome += " " + convert + " |"; + } + } else { + if (j == 5) { + outcome += " " + convert + " |\n"; + } else { + outcome += " " + convert + " |"; + } + } + } + } + + return outcome; } public static String getLargeMultiplicationTable() { - return null; + String outcome = ""; + String convert; + int multiple; + + for (int i = 1; i <= 10; i++) { + for (int j = 1; j <= 10; j++) { + multiple = i * j; + convert = Integer.toString(multiple); + + if (multiple >= 100) { + if (j == 10) { + outcome += "" + convert + " |\n"; + } else { + outcome += "" + convert + " |"; + } + } else if (multiple >= 10){ + if (j == 10) { + outcome += " " + convert + " |\n"; + } else { + outcome += " " + convert + " |"; + } + } else { + if (j == 10) { + outcome += " " + convert + " |\n"; + } else { + outcome += " " + convert + " |"; + } + } + } + } + + return outcome; } public static String getMultiplicationTable(int tableSize) { - return null; + String outcome = ""; + String convert; + int multiple; + + for (int i = 1; i <= tableSize; i++) { + for (int j = 1; j <= tableSize; j++) { + multiple = i * j; + convert = Integer.toString(multiple); + + if (multiple >= 100) { + if (j == tableSize) { + outcome += "" + convert + " |\n"; + } else { + outcome += "" + convert + " |"; + } + } else if (multiple >= 10){ + if (j == tableSize) { + outcome += " " + convert + " |\n"; + } else { + outcome += " " + convert + " |"; + } + } else { + if (j == tableSize) { + outcome += " " + convert + " |\n"; + } else { + outcome += " " + convert + " |"; + } + } + } + } + + return outcome; } -} +} \ No newline at end of file diff --git a/TriangleUtilities.java b/TriangleUtilities.java index 8755fd0..1eb94d0 100644 --- a/TriangleUtilities.java +++ b/TriangleUtilities.java @@ -1,21 +1,45 @@ - - -public class TriangleUtilities { + public class TriangleUtilities { public static String getRow(int numberOfStars) { - return null; + String outcome = ""; + + for (int i = 0; i < numberOfStars; i++) { + outcome += "*"; + } + + return outcome; } public static String getTriangle(int numberOfRows) { - return null; - } + String outcome = ""; + String stars = "*"; + for (int i = 1; i <= numberOfRows; i++) { + outcome += stars.repeat(i) + "\n"; + } + + return outcome; + } public static String getSmallTriangle() { - return null; + String outcome = ""; + String stars = "*"; + + for (int i = 1; i <= 4; i++) { + outcome += stars.repeat(i) + "\n"; + } + + return outcome; } public static String getLargeTriangle() { - return null; + String outcome = ""; + String stars = "*"; + + for (int i = 1; i <= 9; i++) { + outcome += stars.repeat(i) + "\n"; + } + + return outcome; } -} +} \ No newline at end of file diff --git a/package.bluej b/package.bluej index 028bdd0..11fb8a8 100644 --- a/package.bluej +++ b/package.bluej @@ -1,9 +1,9 @@ #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 @@ -12,68 +12,92 @@ 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 +objectbench.height=163 +objectbench.width=901 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.7305863708399366 +package.editor.height=454 +package.editor.width=808 +package.editor.x=245 +package.editor.y=53 +package.frame.height=695 +package.frame.width=925 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=380 +target1.y=120 +target10.association=TriangleUtilitiesTest +target10.height=50 +target10.name=TriangleUtilities +target10.showInterface=false +target10.type=ClassTarget +target10.width=120 +target10.x=210 +target10.y=160 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=260 +target2.y=260 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=240 +target3.y=130 +target4.height=70 +target4.name=README-TableUtilities.md +target4.type=TextTarget +target4.width=170 +target4.x=390 +target4.y=260 +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=230 +target5.y=290 +target6.height=70 +target6.name=README-NumberUtilities.md +target6.type=TextTarget +target6.width=180 +target6.x=350 +target6.y=10 +target7.association=NumberUtilitiesTest +target7.height=50 +target7.name=NumberUtilities +target7.showInterface=false +target7.type=ClassTarget +target7.width=120 +target7.x=180 +target7.y=50 +target8.height=70 +target8.name=README.md +target8.type=TextTarget +target8.width=120 +target8.x=20 +target8.y=90 +target9.height=50 +target9.name=NumberUtilitiesTest +target9.showInterface=false +target9.type=UnitTestTargetJunit4 +target9.width=120 +target9.x=210 +target9.y=20