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..ddf7c5e 100644 --- a/MathUtilities.java +++ b/MathUtilities.java @@ -1,224 +1,224 @@ - + /** - * Created by dan on 6/14/17. - */ +* Created by dan on 6/14/17. +*/ public class MathUtilities { - /** - * @param baseValue starting value - * @param difference value to add to starting value - * @return sum of `baseValue` and `difference` - */ - public Integer add(int baseValue, int difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to add to starting value - * @return sum of `baseValue` and `difference` - */ - public Long add(long baseValue, long difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to add to starting value - * @return sum of `baseValue` and `difference` - */ - public Short add(short baseValue, short difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to add to starting value - * @return sum of `baseValue` and `difference` - */ - public Byte add(byte baseValue, byte difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to add to starting value - * @return sum of `baseValue` and `difference` - */ - public Float add(float baseValue, float difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to add to starting value - * @return sum of `baseValue` and `difference` - */ - public Double add(double baseValue, double difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to subtract from starting value - * @return difference between `baseValue` and `difference` - */ - public Integer subtract(int baseValue, int difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to subtract from starting value - * @return difference between `baseValue` and `difference` - */ - public Long subtract(long baseValue, long difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to subtract from starting value - * @return difference between `baseValue` and `difference` - */ - public Short subtract(short baseValue, short difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to subtract from starting value - * @return difference between `baseValue` and `difference` - */ - public Byte subtract(byte baseValue, byte difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to subtract from starting value - * @return difference between `baseValue` and `difference` - */ - public Float subtract(float baseValue, float difference) { - return null; - } - - /** - * @param baseValue starting value - * @param difference value to subtract from starting value - * @return difference between `baseValue` and `difference` - */ - public Double subtract(double baseValue, double difference) { - return null; - } - - - /** - * @param dividend value to be divided - * @param divisor value to divide by - * @return division of `dividend` by `divisor - */ - public Integer divide(int dividend, int divisor) { - return null; - } - - /** - * @param dividend value to be divided - * @param divisor value to divide by - * @return division of `dividend` by `divisor - */ - public Long divide(long dividend, long divisor) { - return null; - } - - /** - * @param dividend value to be divided - * @param divisor value to divide by - * @return division of `dividend` by `divisor - */ - public Short divide(short dividend, short divisor) { - return null; - } - - /** - * @param dividend value to be divided - * @param divisor value to divide by - * @return division of `dividend` by `divisor - */ - public Byte divide(byte dividend, byte divisor) { - return null; - } - - /** - * @param dividend value to be divided - * @param divisor value to divide by - * @return division of `dividend` by `divisor - */ - public Float divide(float dividend, float divisor) { - return null; - } - - /** - * @param dividend value to be divided - * @param divisor value to divide by - * @return division of `dividend` by `divisor - */ - public Double divide(double dividend, double divisor) { - return null; - } - - - /** - * @param multiplicand value to be multiplied - * @param multiplier value to multiply by - * @return product of `multiplicand` by `multiplier` - */ - public Integer multiply(int multiplicand, int multiplier) { - return null; - } - - /** - * @param multiplicand value to be multiplied - * @param multiplier value to multiply by - * @return product of `multiplicand` by `multiplier` - */ - public Long multiply(long multiplicand, long multiplier) { - return null; - } - - /** - * @param multiplicand value to be multiplied - * @param multiplier value to multiply by - * @return product of `multiplicand` by `multiplier` - */ - public Short multiply(short multiplicand, short multiplier) { - return null; - } - /** - * @param multiplicand value to be multiplied - * @param multiplier value to multiply by - * @return product of `multiplicand` by `multiplier` - */ - public Byte multiply(byte multiplicand, byte multiplier) { - return null; - } - - /** - * @param multiplicand value to be multiplied - * @param multiplier value to multiply by - * @return product of `multiplicand` by `multiplier` - */ - public Float multiply(float multiplicand, float multiplier) { - return null; - } - - /** - * @param multiplicand value to be multiplied - * @param multiplier value to multiply by - * @return product of `multiplicand` by `multiplier` - */ - public Double multiply(double multiplicand, double multiplier) { - return null; - } + /** + * @param baseValue starting value + * @param difference value to add to starting value + * @return sum of `baseValue` and `difference` + */ + public Integer add(int baseValue, int difference) { + return baseValue + difference; + } + + /** + * @param baseValue starting value + * @param difference value to add to starting value + * @return sum of `baseValue` and `difference` + */ + public Long add(long baseValue, long difference) { + return baseValue + difference; + } + + /** + * @param baseValue starting value + * @param difference value to add to starting value + * @return sum of `baseValue` and `difference` + */ + public Short add(short baseValue, short difference) { + return (short)(baseValue + difference); + } + + /** + * @param baseValue starting value + * @param difference value to add to starting value + * @return sum of `baseValue` and `difference` + */ + public Byte add(byte baseValue, byte difference) { + return (byte)(baseValue + difference); + } + + /** + * @param baseValue starting value + * @param difference value to add to starting value + * @return sum of `baseValue` and `difference` + */ + public Float add(float baseValue, float difference) { + return (baseValue + difference); + } + + /** + * @param baseValue starting value + * @param difference value to add to starting value + * @return sum of `baseValue` and `difference` + */ + public Double add(double baseValue, double difference) { + return (baseValue + difference); + } + + /** + * @param baseValue starting value + * @param difference value to subtract from starting value + * @return difference between `baseValue` and `difference` + */ + public Integer subtract(int baseValue, int difference) { + return (baseValue - difference); + } + + /** + * @param baseValue starting value + * @param difference value to subtract from starting value + * @return difference between `baseValue` and `difference` + */ + public Long subtract(long baseValue, long difference) { + return (baseValue - difference); + } + + /** + * @param baseValue starting value + * @param difference value to subtract from starting value + * @return difference between `baseValue` and `difference` + */ + public Short subtract(short baseValue, short difference) { + return (short)(baseValue - difference); + } + + /** + * @param baseValue starting value + * @param difference value to subtract from starting value + * @return difference between `baseValue` and `difference` + */ + public Byte subtract(byte baseValue, byte difference) { + return (byte)(baseValue - difference); + } + + /** + * @param baseValue starting value + * @param difference value to subtract from starting value + * @return difference between `baseValue` and `difference` + */ + public Float subtract(float baseValue, float difference) { + return (baseValue - difference); + } + + /** + * @param baseValue starting value + * @param difference value to subtract from starting value + * @return difference between `baseValue` and `difference` + */ + public Double subtract(double baseValue, double difference) { + return (baseValue - difference); + } + + + /** + * @param dividend value to be divided + * @param divisor value to divide by + * @return division of `dividend` by `divisor + */ + public Integer divide(int dividend, int divisor) { + return dividend / divisor; + } + + /** + * @param dividend value to be divided + * @param divisor value to divide by + * @return division of `dividend` by `divisor + */ + public Long divide(long dividend, long divisor) { + return dividend / divisor; + } + + /** + * @param dividend value to be divided + * @param divisor value to divide by + * @return division of `dividend` by `divisor + */ + public Short divide(short dividend, short divisor) { + return (short)(dividend / divisor); + } + + /** + * @param dividend value to be divided + * @param divisor value to divide by + * @return division of `dividend` by `divisor + */ + public Byte divide(byte dividend, byte divisor) { + return (byte)(dividend / divisor); + } + + /** + * @param dividend value to be divided + * @param divisor value to divide by + * @return division of `dividend` by `divisor + */ + public Float divide(float dividend, float divisor) { + return (dividend / divisor); + } + + /** + * @param dividend value to be divided + * @param divisor value to divide by + * @return division of `dividend` by `divisor + */ + public Double divide(double dividend, double divisor) { + return (dividend / divisor); + } + + + /** + * @param multiplicand value to be multiplied + * @param multiplier value to multiply by + * @return product of `multiplicand` by `multiplier` + */ + public Integer multiply(int multiplicand, int multiplier) { + return (multiplicand * multiplier); + } + + /** + * @param multiplicand value to be multiplied + * @param multiplier value to multiply by + * @return product of `multiplicand` by `multiplier` + */ + public Long multiply(long multiplicand, long multiplier) { + return (multiplicand * multiplier); + } + + /** + * @param multiplicand value to be multiplied + * @param multiplier value to multiply by + * @return product of `multiplicand` by `multiplier` + */ + public Short multiply(short multiplicand, short multiplier) { + return (short)(multiplicand * multiplier); + } + /** + * @param multiplicand value to be multiplied + * @param multiplier value to multiply by + * @return product of `multiplicand` by `multiplier` + */ + public Byte multiply(byte multiplicand, byte multiplier) { + return (byte)(multiplicand * multiplier); + } + + /** + * @param multiplicand value to be multiplied + * @param multiplier value to multiply by + * @return product of `multiplicand` by `multiplier` + */ + public Float multiply(float multiplicand, float multiplier) { + return (multiplicand * multiplier); + } + + /** + * @param multiplicand value to be multiplied + * @param multiplier value to multiply by + * @return product of `multiplicand` by `multiplier` + */ + public Double multiply(double multiplicand, double multiplier) { + return (multiplicand * multiplier); + } } diff --git a/PredicateUtilities.class b/PredicateUtilities.class index 64dfa1b..ceee876 100644 Binary files a/PredicateUtilities.class and b/PredicateUtilities.class differ diff --git a/PredicateUtilities.java b/PredicateUtilities.java index 4b83a87..eca132b 100644 --- a/PredicateUtilities.java +++ b/PredicateUtilities.java @@ -1,57 +1,57 @@ - + /** - * Created by dan on 6/14/17. - */ +* Created by dan on 6/14/17. +*/ public class PredicateUtilities { - /** - * @param x - * @param y - * @return true if `x` is greater than `y` - */ - public Boolean isGreaterThan(int x, int y) { - return null; - } + /** + * @param x + * @param y + * @return true if `x` is greater than `y` + */ + public Boolean isGreaterThan(int x, int y) { + return x > y; + } - /** - * @param x - * @param y - * @return true if `x` is less than `y` - */ - public Boolean isLessThan(int x, int y) { - return null; - } + /** + * @param x + * @param y + * @return true if `x` is less than `y` + */ + public Boolean isLessThan(int x, int y) { + return x < y; + } - /** - * @param x - * @param y - * @return true if `x` is greater than or equal to `y` - */ - public Boolean isGreaterThanOrEqualTo(int x, int y) { - return null; - } + /** + * @param x + * @param y + * @return true if `x` is greater than or equal to `y` + */ + public Boolean isGreaterThanOrEqualTo(int x, int y) { + return x >= y; + } - /** - * @param x - * @param y - * @return true if `x` is less than or equal to `y` - */ - public Boolean isLessThanOrEqualTo(int x, int y) { - return null; - } - - - /** - * @return true - */ - public Boolean returnTrue() { - return null; - } + /** + * @param x + * @param y + * @return true if `x` is less than or equal to `y` + */ + public Boolean isLessThanOrEqualTo(int x, int y) { + return x <= y; + } + + + /** + * @return true + */ + public Boolean returnTrue() { + return true; + } - /** - * @return false - */ - public Boolean returnFalse() { - return null; - } + /** + * @return false + */ + public Boolean returnFalse() { + return false; + } } \ No newline at end of file diff --git a/StringUtilities.class b/StringUtilities.class index 71bb6fd..c8787fb 100644 Binary files a/StringUtilities.class and b/StringUtilities.class differ diff --git a/StringUtilities.java b/StringUtilities.java index b791a2a..f352f0e 100644 --- a/StringUtilities.java +++ b/StringUtilities.java @@ -1,88 +1,99 @@ - + /** - * Created by dan on 6/14/17. - */ +* Created by dan on 6/14/17. +*/ public class StringUtilities { - /** - * @return `Hello World` as a string - */ - public static String getHelloWorld() { - return null; - } + /** + * @return `Hello World` as a string + */ + public static String getHelloWorld() { + return "Hello World"; + } - /** - * @param firstSegment a string to be added to - * @param secondSegment a string to add - * @return the concatenation of two strings, `firstSegment`, and `secondSegment` - */ - public static String concatenation(String firstSegment, String secondSegment){ - return null; - } + /** + * @param firstSegment a string to be added to + * @param secondSegment a string to add + * @return the concatenation of two strings, `firstSegment`, and `secondSegment` + */ + public static String concatenation(String firstSegment, String secondSegment){ + return firstSegment + secondSegment; + } - /** - * @param firstSegment a string to be added to - * @param secondSegment a string to add - * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment` - */ - public static String concatenation(int firstSegment, String secondSegment){ - return null; - } + /** + * @param firstSegment a string to be added to + * @param secondSegment a string to add + * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment` + */ + public static String concatenation(int firstSegment, String secondSegment){ + return Integer.toString(firstSegment) + secondSegment; + } - /** - * @param input a string to be manipulated - * @return the first 3 characters of `input` - */ - public static String getPrefix(String input){ - return null; - } + /** + * @param input a string to be manipulated + * @return the first 3 characters of `input` + */ + public static String getPrefix(String input){ + return input.substring(0,3); + } - /** - * @param input a string to be manipulated - * @return the last 3 characters of `input` - */ - public static String getSuffix(String input){ - return null; - } + /** + * @param input a string to be manipulated + * @return the last 3 characters of `input` + */ + public static String getSuffix(String input){ + return input.substring(input.length() - 3); + } - /** - * @param inputValue the value to be compared - * @param comparableValue the value to be compared against - * @return the equivalence of two strings, `inputValue` and `comparableValue` - */ - public static Boolean compareTwoStrings(String inputValue, String comparableValue){ - return null; - } + /** + * @param inputValue the value to be compared + * @param comparableValue the value to be compared against + * @return the equivalence of two strings, `inputValue` and `comparableValue` + */ + public static Boolean compareTwoStrings(String inputValue, String comparableValue){ + return inputValue.equals(comparableValue); + } - /** - * @param inputValue the value input from user - * @return the middle character of `inputValue` - */ - public static Character getMiddleCharacter(String inputValue){ - return null; - } + /** + * @param inputValue the value input from user + * @return the middle character of `inputValue` + */ + + public static Character getMiddleCharacter(String inputValue){ + int lengthString = inputValue.length(); + int halfString = lengthString / 2; + int option = (halfString % 2 == 0) ? 1 : 0; + char middleChar = inputValue.charAt(halfString - option); + return middleChar; + } - /** - * @param spaceDelimitedString a string, representative of a sentence, containing spaces - * @return the first sequence of characters - */ - public static String getFirstWord(String spaceDelimitedString){ - return null; - } + /** + * @param spaceDelimitedString a string, representative of a sentence, containing spaces + * @return the first sequence of characters + */ + public static String getFirstWord(String spaceDelimitedString){ + return spaceDelimitedString.split(" ")[0]; + } - /** - * @param spaceDelimitedString a string delimited by spaces - * @return the second word of a string delimited by spaces. - */ - public static String getSecondWord(String spaceDelimitedString){ - return null; - } + /** + * @param spaceDelimitedString a string delimited by spaces + * @return the second word of a string delimited by spaces. + */ + public static String getSecondWord(String spaceDelimitedString){ + return spaceDelimitedString.split(" ")[1]; + } - /** - * @param stringToReverse - * @return an identical string with characters in reverse order. - */ - public static String reverse(String stringToReverse){ - return null; - } + /** + * @param stringToReverse + * @return an identical string with characters in reverse order. + */ + public static String reverse(String stringToReverse){ + int lengthString = stringToReverse.length(); + String[] splitWord = stringToReverse.split(""); + String reverseWord = ""; + for(int i = lengthString - 1; i >= 0; i--){ + reverseWord += splitWord[i]; + } + return reverseWord; + } } diff --git a/TestMultiplication.class b/TestMultiplication.class index 6f83618..7b388f1 100644 Binary files a/TestMultiplication.class and b/TestMultiplication.class differ diff --git a/TestMultiplication.java b/TestMultiplication.java index ca937b5..f74931d 100644 --- a/TestMultiplication.java +++ b/TestMultiplication.java @@ -47,7 +47,7 @@ public void testShortMultiplication() { public void testByteMultiplication() { // : Given byte multiplicand = 16; - byte multiplier = 14; + byte multiplier = 4; byte expectedByte = 64; // : When byte actualByte = mathUtils.multiply(multiplicand, multiplier); diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..1885487 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-midnight \ No newline at end of file diff --git a/package.bluej b/package.bluej index 5ded697..90ab3e9 100644 --- a/package.bluej +++ b/package.bluej @@ -3,18 +3,18 @@ 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 +objectbench.height=106 +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.8493333333333334 +package.editor.height=630 +package.editor.width=735 +package.editor.x=100 +package.editor.y=23 +package.frame.height=808 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