diff --git a/src/fr/iut/uca/Operations.java b/src/fr/iut/uca/Operations.java index 9246c19..164fe6f 100644 --- a/src/fr/iut/uca/Operations.java +++ b/src/fr/iut/uca/Operations.java @@ -1,7 +1,7 @@ package fr.iut.uca; public class Operations { - public long Add(long a, long b, long... others) { + public long add(long a, long b, long... others) { long res = a + b; @@ -14,7 +14,7 @@ public class Operations { return res; } - public long Multiply(long a, long b, long... others) { + public long multiply(long a, long b, long... others) { long res = a * b; @@ -27,7 +27,7 @@ public class Operations { return res; } - public long Divide(long a, long b, long... others) { + public long divide(long a, long b, long... others) { if(b == 0) { throw new ArithmeticException("attempted to divide by zero"); } @@ -46,4 +46,16 @@ public class Operations { return res; } + public boolean pythagoras(long a, long b, long c) { + if(a <= 0 || b <= 0 || c <= 0) { + throw new ArithmeticException("there is no such thing as a negative length for a triangle's side"); + } + + return ( + (a * a) + (b * b) == c * c + || (c * c) + (b * b) == a * a + || (a * a) + (c * c) == b * b + ); + } + } diff --git a/src/fr/iut/uca/PleaseEclipseCmon.java b/src/fr/iut/uca/PleaseEclipseCmon.java index f0c315b..c699a20 100644 --- a/src/fr/iut/uca/PleaseEclipseCmon.java +++ b/src/fr/iut/uca/PleaseEclipseCmon.java @@ -5,7 +5,6 @@ public class PleaseEclipseCmon { public static void main(String[] args) { Operations operation = new Operations(); - System.out.println(operation.Add(2, 2, 2, 2, 3)); - System.out.println(0 == -0); + System.out.println(operation.add(2, 2, 2, 2, 3)); } } diff --git a/src/test/OperationsTests.java b/src/test/OperationsTests.java index fd435f3..46b27d7 100644 --- a/src/test/OperationsTests.java +++ b/src/test/OperationsTests.java @@ -28,7 +28,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, null); + long actual = op.add(x, y, null); // Assert @@ -45,7 +45,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, null); + long actual = op.add(x, y, null); // Assert @@ -62,7 +62,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, null); + long actual = op.add(x, y, null); // Assert @@ -79,7 +79,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, null); + long actual = op.add(x, y, null); // Assert @@ -96,7 +96,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, null); + long actual = op.add(x, y, null); // Assert @@ -113,7 +113,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, null); + long actual = op.add(x, y, null); // Assert @@ -130,7 +130,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, null); + long actual = op.add(x, y, null); // Assert @@ -147,7 +147,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, null); + long actual = op.add(x, y, null); // Assert @@ -167,7 +167,7 @@ class OperationsTests { // Act - long actual = op.Add(x, y, z1, z2, z3); + long actual = op.add(x, y, z1, z2, z3); // Assert @@ -176,10 +176,11 @@ class OperationsTests { @Test void rdm() { + Random rdm = new Random(); + for(int i = 0 ; i <10; i++) { // Arrange - Random rdm = new Random(); long rdmX =rdm.nextLong(); long rdmY = rdm.nextLong(); @@ -197,7 +198,7 @@ class OperationsTests { // Act - long actual = op.Add(rdmX, rdmY, null); + long actual = op.add(rdmX, rdmY, null); // Assert