diff --git a/MathUtilities.class b/MathUtilities.class index 4ea9860..8f0b7d4 100644 Binary files a/MathUtilities.class and b/MathUtilities.class differ diff --git a/MathUtilities.java b/MathUtilities.java index 7d4f4fc..0336004 100644 --- a/MathUtilities.java +++ b/MathUtilities.java @@ -11,7 +11,7 @@ public class MathUtilities { * @return sum of `baseValue` and `difference` */ public Integer add(int baseValue, int difference) { - return null; + return baseValue + difference; } /** @@ -20,7 +20,7 @@ public Integer add(int baseValue, int difference) { * @return sum of `baseValue` and `difference` */ public Long add(long baseValue, long difference) { - return null; + return baseValue + difference; } /** @@ -29,7 +29,7 @@ public Long add(long baseValue, long difference) { * @return sum of `baseValue` and `difference` */ public Short add(short baseValue, short difference) { - return null; + return (short) (baseValue + difference); } /** @@ -38,7 +38,7 @@ public Short add(short baseValue, short difference) { * @return sum of `baseValue` and `difference` */ public Byte add(byte baseValue, byte difference) { - return null; + return (byte) (baseValue + difference); } /** @@ -47,7 +47,7 @@ public Byte add(byte baseValue, byte difference) { * @return sum of `baseValue` and `difference` */ public Float add(float baseValue, float difference) { - return null; + return (float) (baseValue + difference); } /** @@ -56,7 +56,7 @@ public Float add(float baseValue, float difference) { * @return sum of `baseValue` and `difference` */ public Double add(double baseValue, double difference) { - return null; + return (double) (baseValue + difference); } /** @@ -65,7 +65,7 @@ public Double add(double baseValue, double difference) { * @return difference between `baseValue` and `difference` */ public Integer subtract(int baseValue, int difference) { - return null; + return baseValue - difference; } /** @@ -74,7 +74,7 @@ public Integer subtract(int baseValue, int difference) { * @return difference between `baseValue` and `difference` */ public Long subtract(long baseValue, long difference) { - return null; + return baseValue - difference; } /** @@ -83,7 +83,7 @@ public Long subtract(long baseValue, long difference) { * @return difference between `baseValue` and `difference` */ public Short subtract(short baseValue, short difference) { - return null; + return (short) (baseValue - difference); } /** @@ -92,7 +92,7 @@ public Short subtract(short baseValue, short difference) { * @return difference between `baseValue` and `difference` */ public Byte subtract(byte baseValue, byte difference) { - return null; + return (byte) (baseValue - difference); } /** @@ -101,7 +101,7 @@ public Byte subtract(byte baseValue, byte difference) { * @return difference between `baseValue` and `difference` */ public Float subtract(float baseValue, float difference) { - return null; + return (float) (baseValue - difference); } /** @@ -110,7 +110,7 @@ public Float subtract(float baseValue, float difference) { * @return difference between `baseValue` and `difference` */ public Double subtract(double baseValue, double difference) { - return null; + return (double) (baseValue - difference); } @@ -120,7 +120,7 @@ public Double subtract(double baseValue, double difference) { * @return division of `dividend` by `divisor */ public Integer divide(int dividend, int divisor) { - return null; + return dividend / divisor; } /** @@ -129,7 +129,7 @@ public Integer divide(int dividend, int divisor) { * @return division of `dividend` by `divisor */ public Long divide(long dividend, long divisor) { - return null; + return dividend / divisor; } /** @@ -138,7 +138,7 @@ public Long divide(long dividend, long divisor) { * @return division of `dividend` by `divisor */ public Short divide(short dividend, short divisor) { - return null; + return (short) (dividend / divisor); } /** @@ -147,7 +147,7 @@ public Short divide(short dividend, short divisor) { * @return division of `dividend` by `divisor */ public Byte divide(byte dividend, byte divisor) { - return null; + return (byte) (dividend / divisor); } /** @@ -156,7 +156,7 @@ public Byte divide(byte dividend, byte divisor) { * @return division of `dividend` by `divisor */ public Float divide(float dividend, float divisor) { - return null; + return (float) (dividend / divisor); } /** @@ -165,7 +165,7 @@ public Float divide(float dividend, float divisor) { * @return division of `dividend` by `divisor */ public Double divide(double dividend, double divisor) { - return null; + return (double) (dividend / divisor); } @@ -175,7 +175,7 @@ public Double divide(double dividend, double divisor) { * @return product of `multiplicand` by `multiplier` */ public Integer multiply(int multiplicand, int multiplier) { - return null; + return multiplicand * multiplier; } /** @@ -184,7 +184,7 @@ public Integer multiply(int multiplicand, int multiplier) { * @return product of `multiplicand` by `multiplier` */ public Long multiply(long multiplicand, long multiplier) { - return null; + return multiplicand * multiplier; } /** @@ -193,7 +193,7 @@ public Long multiply(long multiplicand, long multiplier) { * @return product of `multiplicand` by `multiplier` */ public Short multiply(short multiplicand, short multiplier) { - return null; + return (short) (multiplicand * multiplier); } /** * @param multiplicand value to be multiplied @@ -201,7 +201,7 @@ public Short multiply(short multiplicand, short multiplier) { * @return product of `multiplicand` by `multiplier` */ public Byte multiply(byte multiplicand, byte multiplier) { - return null; + return (byte) (multiplicand * multiplier); } /** @@ -210,7 +210,7 @@ public Byte multiply(byte multiplicand, byte multiplier) { * @return product of `multiplicand` by `multiplier` */ public Float multiply(float multiplicand, float multiplier) { - return null; + return (float) (multiplicand * multiplier); } /** @@ -219,6 +219,6 @@ public Float multiply(float multiplicand, float multiplier) { * @return product of `multiplicand` by `multiplier` */ public Double multiply(double multiplicand, double multiplier) { - return null; + return (double) (multiplicand * multiplier); } } diff --git a/PredicateUtilities.class b/PredicateUtilities.class index 64dfa1b..5af8bf5 100644 Binary files a/PredicateUtilities.class and b/PredicateUtilities.class differ diff --git a/PredicateUtilities.ctxt b/PredicateUtilities.ctxt index d46571c..e59f256 100644 --- a/PredicateUtilities.ctxt +++ b/PredicateUtilities.ctxt @@ -9,7 +9,7 @@ comment2.target=java.lang.Boolean\ isLessThan(int,\ int) comment2.text=\n\ @param\ x\n\ @param\ y\n\ @return\ true\ if\ `x`\ is\ less\ than\ `y`\n comment3.params=x\ y comment3.target=java.lang.Boolean\ isGreaterThanOrEqualTo(int,\ int) -comment3.text=\n\ @param\ x\n\ @param\ y\n\ @return\ true\ if\ `x`\ is\ greater\ than\ or\ equal\ to\ `y`\n +comment3.text=\n\ @param\ x\n\ @param\n\ @return\ true\ if\ `x`\ is\ greater\ than\ or\ equal\ to\ `y`\n comment4.params=x\ y comment4.target=java.lang.Boolean\ isLessThanOrEqualTo(int,\ int) comment4.text=\n\ @param\ x\n\ @param\ y\n\ @return\ true\ if\ `x`\ is\ less\ than\ or\ equal\ to\ `y`\n diff --git a/PredicateUtilities.java b/PredicateUtilities.java index 4b83a87..d1c1eb3 100644 --- a/PredicateUtilities.java +++ b/PredicateUtilities.java @@ -1,4 +1,4 @@ - + /** * Created by dan on 6/14/17. @@ -10,25 +10,38 @@ public class PredicateUtilities { * @return true if `x` is greater than `y` */ public Boolean isGreaterThan(int x, int y) { - return null; + if(x > y) { + return true; + }else { + return false; + } } + /** * @param x * @param y * @return true if `x` is less than `y` */ public Boolean isLessThan(int x, int y) { - return null; + if(x < y) { + return true; + }else { + return false; + } } /** * @param x - * @param y + * @param * @return true if `x` is greater than or equal to `y` */ public Boolean isGreaterThanOrEqualTo(int x, int y) { - return null; + if( x >= y) { + return true; + }else { + return false; + } } /** @@ -37,7 +50,11 @@ public Boolean isGreaterThanOrEqualTo(int x, int y) { * @return true if `x` is less than or equal to `y` */ public Boolean isLessThanOrEqualTo(int x, int y) { - return null; + if( x <= y) { + return true; + }else { + return false; + } } @@ -45,13 +62,13 @@ public Boolean isLessThanOrEqualTo(int x, int y) { * @return true */ public Boolean returnTrue() { - return null; + return true; } /** * @return false */ public Boolean returnFalse() { - return null; + return false; } } \ No newline at end of file diff --git a/StringUtilities.class b/StringUtilities.class index 71bb6fd..63bf378 100644 Binary files a/StringUtilities.class and b/StringUtilities.class differ diff --git a/StringUtilities.java b/StringUtilities.java index b791a2a..12e5cf1 100644 --- a/StringUtilities.java +++ b/StringUtilities.java @@ -8,7 +8,7 @@ public class StringUtilities { * @return `Hello World` as a string */ public static String getHelloWorld() { - return null; + return "Hello World"; } /** @@ -17,7 +17,9 @@ public static String getHelloWorld() { * @return the concatenation of two strings, `firstSegment`, and `secondSegment` */ public static String concatenation(String firstSegment, String secondSegment){ - return null; + String convert = String.valueOf(firstSegment); + String combined = convert + secondSegment; + return combined; } /** @@ -26,7 +28,7 @@ public static String concatenation(String firstSegment, String secondSegment){ * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment` */ public static String concatenation(int firstSegment, String secondSegment){ - return null; + return "firstSegment + secondSegment"; } /** @@ -34,7 +36,9 @@ public static String concatenation(int firstSegment, String secondSegment){ * @return the first 3 characters of `input` */ public static String getPrefix(String input){ - return null; + + + return input.substring(0,3); } /** @@ -42,7 +46,7 @@ public static String getPrefix(String input){ * @return the last 3 characters of `input` */ public static String getSuffix(String input){ - return null; + return input.substring(input.length() - 3, input.length()); } /** @@ -51,7 +55,9 @@ public static String getSuffix(String input){ * @return the equivalence of two strings, `inputValue` and `comparableValue` */ public static Boolean compareTwoStrings(String inputValue, String comparableValue){ - return null; + if (inputValue==comparableValue) { + return true; + }else {return false;} } /** @@ -59,7 +65,8 @@ public static Boolean compareTwoStrings(String inputValue, String comparableValu * @return the middle character of `inputValue` */ public static Character getMiddleCharacter(String inputValue){ - return null; + int mid = (inputValue.length()-1)/2; + return inputValue.charAt(mid); } /** @@ -67,7 +74,8 @@ public static Character getMiddleCharacter(String inputValue){ * @return the first sequence of characters */ public static String getFirstWord(String spaceDelimitedString){ - return null; + String[] words = spaceDelimitedString.split(" "); + return words[0]; } /** @@ -75,7 +83,8 @@ public static String getFirstWord(String spaceDelimitedString){ * @return the second word of a string delimited by spaces. */ public static String getSecondWord(String spaceDelimitedString){ - return null; + String[] words = spaceDelimitedString.split(" "); + return words [1]; } /** @@ -83,6 +92,9 @@ public static String getSecondWord(String spaceDelimitedString){ * @return an identical string with characters in reverse order. */ public static String reverse(String stringToReverse){ - return null; + String reverse = " "; + for (int i = stringToReverse.length() - 1; i >=0; i --) { + reverse += stringToReverse.charAt(i); + } return reverse; } } diff --git a/package.bluej b/package.bluej index 5ded697..0a01f12 100644 --- a/package.bluej +++ b/package.bluej @@ -1,20 +1,20 @@ #BlueJ package file -editor.fx.0.height=0 -editor.fx.0.width=0 -editor.fx.0.x=0 -editor.fx.0.y=0 -objectbench.height=129 -objectbench.width=531 +editor.fx.0.height=721 +editor.fx.0.width=800 +editor.fx.0.x=240 +editor.fx.0.y=23 +objectbench.height=164 +objectbench.width=837 package.divider.horizontal=0.6397146254458977 -package.divider.vertical=0.8697318007662835 -package.editor.height=901 -package.editor.width=727 -package.editor.x=1440 -package.editor.y=0 -package.frame.height=1080 +package.divider.vertical=0.6138763197586727 +package.editor.height=400 +package.editor.width=735 +package.editor.x=100 +package.editor.y=23 +package.frame.height=721 package.frame.width=861 package.numDependencies=0 -package.numTargets=6 +package.numTargets=9 package.showExtends=true package.showUses=true project.charset=UTF-8 @@ -27,7 +27,6 @@ target1.height=50 target1.name=PredicateUtilities target1.showInterface=false target1.type=ClassTarget -target1.typeParameters= target1.width=130 target1.x=280 target1.y=120 @@ -35,39 +34,55 @@ target2.height=50 target2.name=StringUtilitiesTest target2.showInterface=false target2.type=UnitTestTargetJunit4 -target2.typeParameters= target2.width=140 target2.x=490 target2.y=70 target3.height=50 -target3.name=MathUtilities +target3.name=TestMultiplication target3.showInterface=false -target3.type=ClassTarget -target3.typeParameters= -target3.width=100 -target3.x=60 -target3.y=150 +target3.type=UnitTestTargetJunit4 +target3.width=140 +target3.x=70 +target3.y=60 target4.height=50 -target4.name=PredicateUtilitiesTest +target4.name=TestDivision target4.showInterface=false target4.type=UnitTestTargetJunit4 -target4.typeParameters= -target4.width=160 -target4.x=260 -target4.y=50 +target4.width=100 +target4.x=170 +target4.y=120 target5.height=50 -target5.name=StringUtilities +target5.name=TestSubtraction target5.showInterface=false -target5.type=ClassTarget -target5.typeParameters= -target5.width=110 -target5.x=500 -target5.y=130 +target5.type=UnitTestTargetJunit4 +target5.width=120 +target5.x=10 +target5.y=210 target6.height=50 -target6.name=MathUtilitiesTest +target6.name=MathUtilities target6.showInterface=false -target6.type=UnitTestTargetJunit4 -target6.typeParameters= -target6.width=130 -target6.x=50 -target6.y=90 +target6.type=ClassTarget +target6.width=100 +target6.x=60 +target6.y=150 +target7.height=50 +target7.name=StringUtilities +target7.showInterface=false +target7.type=ClassTarget +target7.width=110 +target7.x=500 +target7.y=130 +target8.height=50 +target8.name=PredicateUtilitiesTest +target8.showInterface=false +target8.type=UnitTestTargetJunit4 +target8.width=160 +target8.x=260 +target8.y=50 +target9.height=50 +target9.name=TestAddition +target9.showInterface=false +target9.type=UnitTestTargetJunit4 +target9.width=100 +target9.x=170 +target9.y=180