Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Reimplementation of the Math class to be used as an example for Unit Testing.
public final class Math {
public static int add(int first, int second) {
return firstNumber + secondNumber;
}
public static int multiply(int multiplicand, int multiplier) {
return multiplicand * multiplier;
}
public static double divide(int dividend, int divisor) {
if (divisor == 0)
throw new IllegalArgumentException("Cannot divide by zero (0).");
return dividend / divisor;
}
}
@nickBlack4

This comment has been minimized.

Copy link

commented Jun 18, 2019

thanks!

@ByWaleed

This comment has been minimized.

Copy link

commented Aug 17, 2019

public static int add(int first, int second) {
        return firstNumber + secondNumber;
}

Variable names don't match.

@maginc

This comment has been minimized.

Copy link

commented Oct 12, 2019

public static int add(int first, int second) {
        return firstNumber + secondNumber;
}

Variable names don't match.

this

@ByWaleed

This comment has been minimized.

Copy link

commented Oct 13, 2019

public static int add(int first, int second) {
        return firstNumber + secondNumber;
}

Variable names don't match.

this

Ye, should it not be like this:

public static int add(int first, int second) {
       return first + second;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.