From d9720ad3abb9c339c5b650b994c24318e0e231d3 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 25 Jun 2021 20:03:05 -0400 Subject: [PATCH] Finished the whole package with the noble assistance of Nathan, the God himself --- NumberUtilities.java | 68 +++++++++++++++++-- README-TableUtilities.md | 13 ++-- README-TriangleUtilities.md | 2 +- README.md | 52 +++++++------- TableUtilities.java | 73 ++++++++++++++++++-- TriangleUtilities.java | 38 +++++++++-- package.bluej | 132 +++++++++++++++++++++--------------- 7 files changed, 277 insertions(+), 101 deletions(-) diff --git a/NumberUtilities.java b/NumberUtilities.java index 1d5ba50..69f9ae3 100644 --- a/NumberUtilities.java +++ b/NumberUtilities.java @@ -4,29 +4,83 @@ public class NumberUtilities { public static String getRange(int stop) { - return null; + + String result = ""; + for (int i = 0; i < stop ; i++) { + result += i; + } + return result; + } public static String getRange(int start, int stop) { - return null; + String result = ""; + for (int i = start; i < stop; i++) { + result += i; + } + return result; } public static String getRange(int start, int stop, int step) { - return null; + String result = ""; + for (int i = start; i < stop; i+=step) { + result += i; + + } + + + return result; } public static String getEvenNumbers(int start, int stop) { - return null; + String result = ""; + int rem = start % 2; + + + if (rem != 0) { + for (int i = start+1; i < stop; i+=2) { + result += i; + + } + return result; + } else { + + for (int i = start; i < stop; i+=2) { + result += i; + + } + + + return result; + } } public static String getOddNumbers(int start, int stop) { - return null; + String result = ""; + int rem = start % 2; + + + for (int i = start; i < stop; i+=2) { + result += i; + + } + return result; + } public static String getExponentiations(int start, int stop, int exponent) { - return null; - } + + String result = ""; + + for (int i = start; i <= stop; i++) { + + int a = (int)Math.pow(i,exponent); + result += a; + } return result; + } + } + diff --git a/README-TableUtilities.md b/README-TableUtilities.md index 535699c..0a549ae 100644 --- a/README-TableUtilities.md +++ b/README-TableUtilities.md @@ -1,5 +1,10 @@ # TableUtilities -* Ensure each of the test cases in the class [TableUtilitiesTest](https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/test/java/io/zipcoder/microlabs/mastering_loops/TableUtilitiesTest.java) successfully passes upon completion of each of the method stubs in the class [TableUtilities](https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/main/java/io/zipcoder/microlabs/mastering_loops/TableUtilities.java). +* Ensure each of the test cases in the class +* [TableUtilitiesTest] +* (https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/test/java/io/zipcoder/microlabs/mastering_loops/TableUtilitiesTest.java) +* successfully passes upon completion of each of the +* method stubs in the class [TableUtilities] +* (https://github.com/Zipcoder/CR-MicroLabs-Loops-NumbersTrianglesTables/blob/master/src/main/java/io/zipcoder/microlabs/mastering_loops/TableUtilities.java). * `String getLargeMultiplicationTable()` * `String getSmallMultiplicationTable()` * `String getMultiplicationTable(int width)` @@ -39,7 +44,7 @@ ## `String getSmallMultiplicationTable()` * **Description** * Generate a `String` representation of a multiplication table whose dimensions are `4` by `4` - + ### Example 1 * Sample Script @@ -107,7 +112,7 @@ * **Description** * Generate a `String` representation of a multiplication table whose dimensions are `9` by `9` - + ### Example * Sample Script @@ -176,7 +181,7 @@ * **Description** * Given one integer, `width`, generate a `String` representation of a multiplication table whose dimensions are `width` by `width` - + ### Example 1 * Sample Script diff --git a/README-TriangleUtilities.md b/README-TriangleUtilities.md index d489661..5a345ae 100644 --- a/README-TriangleUtilities.md +++ b/README-TriangleUtilities.md @@ -125,7 +125,7 @@ * **Description** * Given one integer, `n`, generate a `String` representation of a triangle whose base height and width is equal to `n`. - + ### Example * Sample Script diff --git a/README.md b/README.md index 4421908..9e733d9 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ -# Leon's Loopy Lab -* Read each of the following `README` files and complete each of the asks. - * [README-NumberUtilities.md](./README-NumberUtilities.md) - * [README-TriangleUtilities.md](./README-TriangleUtilities.md) - * [README-TableUtilities.md](./README-TableUtilities.md) - - - - - - - - - - - - - - - - - - - - - +# Leon's Loopy Lab +* Read each of the following `README` files and complete each of the asks. + * [README-NumberUtilities.md](./README-NumberUtilities.md) + * [README-TriangleUtilities.md](./README-TriangleUtilities.md) + * [README-TableUtilities.md](./README-TableUtilities.md) + + + + + + + + + + + + + + + + + + + + + diff --git a/TableUtilities.java b/TableUtilities.java index 03bf004..279baa2 100644 --- a/TableUtilities.java +++ b/TableUtilities.java @@ -2,14 +2,77 @@ public class TableUtilities { public static String getSmallMultiplicationTable() { - return null; + String badBoy = ""; + + for(int i=1; i<=5; i++){ + + for(int j=1; j<=5; j++){ + int d = i * j; + String f = String.valueOf(d); + String o = " "; + if ( f.length() == 2) { + o = " "; + + } else if ( f.length() == 3) { + o = ""; + } + System.out.print(badBoy += o + i*j + " |"); + } + badBoy += "\n"; + + } + + return badBoy; } - + + public static String getLargeMultiplicationTable() { - return null; + String badBoy = ""; + + for(int i=1; i<=10; i++){ + + for(int j=1; j<=10; j++){ + int d = i * j; + String f = String.valueOf(d); + String o = " "; + if ( f.length() == 2) { + o = " "; + + } else if ( f.length() == 3) { + o = ""; + } + System.out.print(badBoy += o + i*j + " |"); + } + badBoy += "\n"; + + } + + return badBoy; } public static String getMultiplicationTable(int tableSize) { - return null; + String badBoy = ""; + + for(int i=1; i<= tableSize; i++){ + + for(int j=1; j<= tableSize; j++){ + int d = i * j; + String f = String.valueOf(d); + String o = " "; + if ( f.length() == 2) { + o = " "; + + } else if ( f.length() == 3) { + o = ""; + } + System.out.print(badBoy += o + i*j + " |"); + } + badBoy += "\n"; + + } + + return badBoy; + } + } -} + diff --git a/TriangleUtilities.java b/TriangleUtilities.java index 8755fd0..b5e92f1 100644 --- a/TriangleUtilities.java +++ b/TriangleUtilities.java @@ -3,19 +3,49 @@ public class TriangleUtilities { public static String getRow(int numberOfStars) { - return null; + String result = ""; + + for(int i = 0; i < numberOfStars; i++) { + result += "*"; + } + return result; } public static String getTriangle(int numberOfRows) { - return null; + String result = ""; + for(int i = 0; i < numberOfRows; i++){ + for(int j = 0; j <= i; j++){ + result += "*"; + } + result += "\n"; + } + return result; + + } public static String getSmallTriangle() { - return null; + String result = ""; + for(int i = 0; i <= 3; i++){ + for(int j = 0; j <= i; j++){ + result += "*"; + } + result += "\n"; + } + return result; + } public static String getLargeTriangle() { - return null; + String result = ""; + for(int i = 0; i < 9; i++){ + for(int j = 0; j <= i; j++){ + result += "*"; + } + result += "\n"; + } + return result; + } } diff --git a/package.bluej b/package.bluej index 028bdd0..23bfeff 100644 --- a/package.bluej +++ b/package.bluej @@ -8,72 +8,96 @@ 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=689 +editor.fx.0.width=724 +editor.fx.0.x=512 +editor.fx.0.y=69 +objectbench.height=66 +objectbench.width=450 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.8021680216802168 +package.editor.height=289 +package.editor.width=340 +package.editor.x=28 +package.editor.y=30 +package.frame.height=427 +package.frame.width=474 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=0 +target1.y=230 +target10.association=TriangleUtilitiesTest +target10.height=50 +target10.name=TriangleUtilities +target10.showInterface=false +target10.type=ClassTarget +target10.width=120 +target10.x=80 +target10.y=250 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=110 +target2.y=150 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=110 +target3.y=220 +target4.height=70 +target4.name=README-TableUtilities.md +target4.type=TextTarget +target4.width=170 +target4.x=0 +target4.y=160 +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=80 +target5.y=180 +target6.height=70 +target6.name=README-NumberUtilities.md +target6.type=TextTarget +target6.width=180 +target6.x=0 +target6.y=310 +target7.association=NumberUtilitiesTest +target7.height=50 +target7.name=NumberUtilities +target7.showInterface=false +target7.type=ClassTarget +target7.width=120 +target7.x=90 +target7.y=330 +target8.height=70 +target8.name=README.md +target8.type=TextTarget +target8.width=120 +target8.x=0 +target8.y=70 +target9.height=50 +target9.name=NumberUtilitiesTest +target9.showInterface=false +target9.type=UnitTestTargetJunit4 +target9.width=120 +target9.x=120 +target9.y=300