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

lab #91

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

lab #91

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
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.zipcodewilmington.danny_do_better_exercises;

import java.nio.ByteBuffer;

/**
* Created by dan on 6/14/17.
*/
Expand All @@ -11,7 +13,8 @@ public class MathUtilities {
* @return sum of `baseValue` and `difference`
*/
public Integer add(int baseValue, int difference) {
return null;

return baseValue + difference;
}

/**
Expand All @@ -20,16 +23,20 @@ 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;
}

/**
* @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;
public int add(short baseValue, short difference) {

int i = baseValue;
int j = difference;
return i + j;

}

/**
Expand All @@ -38,7 +45,11 @@ 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);



}

/**
Expand All @@ -47,7 +58,7 @@ public Byte add(byte baseValue, byte difference) {
* @return sum of `baseValue` and `difference`
*/
public Float add(float baseValue, float difference) {
return null;
return baseValue + difference;
}

/**
Expand All @@ -56,7 +67,8 @@ public Float add(float baseValue, float difference) {
* @return sum of `baseValue` and `difference`
*/
public Double add(double baseValue, double difference) {
return null;
return baseValue + difference;

}

/**
Expand All @@ -65,7 +77,8 @@ 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;
}

/**
Expand All @@ -74,7 +87,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;
}

/**
Expand All @@ -83,7 +96,8 @@ 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);
}

/**
Expand All @@ -92,7 +106,8 @@ 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);
}

/**
Expand All @@ -101,7 +116,8 @@ public Byte subtract(byte baseValue, byte difference) {
* @return difference between `baseValue` and `difference`
*/
public Float subtract(float baseValue, float difference) {
return null;

return baseValue - difference;
}

/**
Expand All @@ -110,115 +126,125 @@ public Float subtract(float baseValue, float difference) {
* @return difference between `baseValue` and `difference`
*/
public Double subtract(double baseValue, double difference) {
return null;

return baseValue - difference;
}


/**
* @param dividend value to be divided
* @param divisor value to divide by
* @param divisor value to divide by
* @return division of `dividend` by `divisor
*/
public Integer divide(int dividend, int divisor) {
return null;

return dividend / divisor;
}

/**
* @param dividend value to be divided
* @param divisor value to divide by
* @param divisor value to divide by
* @return division of `dividend` by `divisor
*/
public Long divide(long dividend, long divisor) {
return null;

return dividend / divisor;
}

/**
* @param dividend value to be divided
* @param divisor value to divide by
* @param divisor value to divide by
* @return division of `dividend` by `divisor
*/
public Short divide(short dividend, short divisor) {
return null;
return (short)(dividend / divisor);
}

/**
* @param dividend value to be divided
* @param divisor value to divide by
* @param divisor value to divide by
* @return division of `dividend` by `divisor
*/
public Byte divide(byte dividend, byte divisor) {
return null;
return (byte)(dividend / divisor);
}

/**
* @param dividend value to be divided
* @param divisor value to divide by
* @param divisor value to divide by
* @return division of `dividend` by `divisor
*/
public Float divide(float dividend, float divisor) {
return null;

return dividend / divisor;
}

/**
* @param dividend value to be divided
* @param divisor value to divide by
* @param divisor value to divide by
* @return division of `dividend` by `divisor
*/
public Double divide(double dividend, double divisor) {
return null;
return dividend / divisor;
}


/**
* @param multiplicand value to be multiplied
* @param multiplier value to multiply by
* @param multiplier value to multiply by
* @return product of `multiplicand` by `multiplier`
*/
public Integer multiply(int multiplicand, int multiplier) {
return null;

return multiplicand * multiplier;
}

/**
* @param multiplicand value to be multiplied
* @param multiplier value to multiply by
* @param multiplier value to multiply by
* @return product of `multiplicand` by `multiplier`
*/
public Long multiply(long multiplicand, long multiplier) {
return null;

return multiplicand * multiplier;
}

/**
* @param multiplicand value to be multiplied
* @param multiplier value to multiply by
* @param multiplier value to multiply by
* @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
* @param multiplier value to multiply by
* @param multiplier value to multiply by
* @return product of `multiplicand` by `multiplier`
*/
public Byte multiply(byte multiplicand, byte multiplier) {
return null;
return (byte)(multiplicand * multiplier);
}

/**
* @param multiplicand value to be multiplied
* @param multiplier value to multiply by
* @param multiplier value to multiply by
* @return product of `multiplicand` by `multiplier`
*/
public Float multiply(float multiplicand, float multiplier) {
return null;

return multiplicand * multiplier;
}

/**
* @param multiplicand value to be multiplied
* @param multiplier value to multiply by
* @param multiplier value to multiply by
* @return product of `multiplicand` by `multiplier`
*/
public Double multiply(double multiplicand, double multiplier) {
return null;

return multiplicand * multiplier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class PredicateUtilities {
* @return true if `x` is greater than `y`
*/
public Boolean isGreaterThan(int x, int y) {
return null;
if ()
}

/**
Expand All @@ -19,7 +19,10 @@ public Boolean isGreaterThan(int x, int y) {
* @return true if `x` is less than `y`
*/
public Boolean isLessThan(int x, int y) {
return null;
if (x < y) {
return true;
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public class StringUtilities {
* @return `Hello World` as a string
*/
public static String getHelloWorld() {
return null;

return "Hello World";
}

/**
Expand All @@ -17,7 +18,7 @@ public static String getHelloWorld() {
* @return the concatenation of two strings, `firstSegment`, and `secondSegment`
*/
public static String concatenation(String firstSegment, String secondSegment){
return null;
return firstSegment.concat(secondSegment);
}

/**
Expand All @@ -26,23 +27,25 @@ 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;
}

/**
* @param input a string to be manipulated
* @return the first 3 characters of `input`
*/
public static String getPrefix(String input){
return null;
return input.substring(0, 2);
}

/**
* @param input a string to be manipulated
* @return the last 3 characters of `input`
*/
public static String getSuffix(String input){
return null;
return input.substring(input.length() - 2, input.length());

}

/**
Expand All @@ -51,15 +54,18 @@ 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.equals(comparableValue))
return true;
}

/**
* @param inputValue the value input from user
* @return the middle character of `inputValue`
*/
public static Character getMiddleCharacter(String inputValue){
return null;
int length = inputValue.length();
int middle = length / 2;
return inputValue.substring(middle); // not sure from here
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/
public class ZipcodeRocks {
public static void main(String[] args) {
// System.out.println("Zipcode Rocks!");
System.out.println("Zipcode Rocks!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void testShortAddition() {
short addedValue = 7;
short expected = 16391;
// : When
short actual = mathUtils.add(baseValue, addedValue);
short actual = (short) mathUtils.add(baseValue, addedValue);
// : Then
assertEquals(expected, actual);
}
Expand Down