Browse Source

5.11.24 TriangleCheckerTest + TriangleCheckerTest mit Anpassung für Gleischenkliges Dreieck

master
marti 2 weeks ago
parent
commit
4412fa436a
2 changed files with 16 additions and 5 deletions
  1. 4
    0
      Test/praktikum02/TriangleCheckerTest.java
  2. 12
    5
      src/praktikum02/TriangleChecker.java

+ 4
- 0
Test/praktikum02/TriangleCheckerTest.java View File

@@ -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));

+ 12
- 5
src/praktikum02/TriangleChecker.java View File

@@ -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;
}
}



}

Loading…
Cancel
Save