@@ -15,6 +15,10 @@ class TriangleCheckerTest { | |||
assertEquals(TriangleChecker.TriangleType.EQUILATERAL,TriangleChecker.checkTriangle(1, 1, 1)); | |||
} | |||
@Test | |||
void checkIsocelesTriangle(){ | |||
assertEquals(TriangleChecker.TriangleType.ISOSCELES,TriangleChecker.checkTriangle(5, 5, 1)); | |||
} | |||
@Test | |||
void checkNegativ() { | |||
assertEquals(TriangleChecker.TriangleType.NONE, TriangleChecker.checkTriangle(-1, 3, 5)); | |||
assertEquals(TriangleChecker.TriangleType.NONE, TriangleChecker.checkTriangle(3, 0, 5)); |
@@ -49,14 +49,21 @@ public class TriangleChecker { | |||
// Analyse der Dreiecksart | |||
public static TriangleType checkTriangle(float a, float b, float c) { | |||
if(a==b && b==c){ | |||
if (a + b <= c || a + c <= b || b + c <= a) { | |||
return TriangleType.NONE; | |||
} | |||
if (a <= 0 || b <= 0 || c <= 0) { | |||
return TriangleType.NONE; | |||
} | |||
if (a == b && b == c) { | |||
return TriangleType.EQUILATERAL; | |||
} | |||
else { | |||
return TriangleType.NORMAL; | |||
if (a == b || b == c || a == c) { | |||
return TriangleType.ISOSCELES; | |||
} | |||
return TriangleType.NORMAL; | |||
} | |||
} | |||
} |