mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-09 03:59:38 +08:00
Add assert statement
This commit is contained in:
@ -10,6 +10,9 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class AbsoluteMax {
|
||||
public static void main(String[] args) {
|
||||
int[] testnums = new int[]{-2, 0, 16};
|
||||
assert absMax(testnums) == 16;
|
||||
|
||||
int[] numbers = new int[]{3, -10, -2};
|
||||
System.out.println("absMax(" + Arrays.toString(numbers) + ") = " + absMax(numbers));
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ import java.util.Arrays;
|
||||
*/
|
||||
public class AbsoluteMin {
|
||||
public static void main(String[] args) {
|
||||
int[] testnums = new int[]{4, 0, 16};
|
||||
assert absMin(testnums) == 0;
|
||||
|
||||
int[] numbers = new int[]{3, -10, -2};
|
||||
System.out.println("absMin(" + Arrays.toString(numbers) + ") = " + absMin(numbers));
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package Maths;
|
||||
|
||||
/**
|
||||
* @author PatOnTheBack
|
||||
*/
|
||||
|
||||
public class AbsoluteValue {
|
||||
|
||||
public static void main(String[] args) {
|
||||
assert absVal(-13) == 13;
|
||||
assert absVal(0) == 0;
|
||||
assert absVal(100) == 100;
|
||||
|
||||
int value = -34;
|
||||
System.out.println("The absolute value of " + value + " is " + absVal(value));
|
||||
}
|
||||
|
@ -17,6 +17,11 @@ public class MaxValue {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
assert max(-3,3) == 3;
|
||||
assert max(-6,-20) == -6;
|
||||
assert max(100,32) == 100;
|
||||
assert max(13,13) == 13;
|
||||
|
||||
int a = 3;
|
||||
int b = 4;
|
||||
System.out.format("max:%d between %d and %d", max(a, b), a, b);
|
||||
|
@ -17,6 +17,11 @@ public class MinValue {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
assert min(-3,3) == -3;
|
||||
assert min(-6,-20) == -20;
|
||||
assert min(100,32) == 32;
|
||||
assert min(13,13) == 13;
|
||||
|
||||
int a = 3;
|
||||
int b = 4;
|
||||
System.out.format("min:%d between %d and %d", min(a, b), a, b);
|
||||
|
Reference in New Issue
Block a user