Browse Source

added check for ISOSCELES

master
Tim Lachmann 1 month ago
parent
commit
ad1d3afbdd
2 changed files with 10 additions and 2 deletions
  1. 5
    2
      src/Praktikum02/TriangleChecker.java
  2. 5
    0
      test/Praktikum02/TriangleCheckerTest.java

+ 5
- 2
src/Praktikum02/TriangleChecker.java View File

@@ -51,10 +51,13 @@ public class TriangleChecker {
public static TriangleType checkTriangle(float a, float b, float c) {

if(a + b > c && a + c > b && b + c > a){
if (a == b || b == c || a == c){
return TriangleType.ISOSCELES;
}
return TriangleType.NORMAL;
} else {
return TriangleType.NONE;
}
return TriangleType.NONE;



}

+ 5
- 0
test/Praktikum02/TriangleCheckerTest.java View File

@@ -15,4 +15,9 @@ class TriangleCheckerTest {
void checkTriangleNone(){
assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(6,2.9f, 2));
}

@Test
void checkTriangleISOSCELES(){
assertEquals(TriangleChecker.TriangleType.ISOSCELES,TriangleChecker.checkTriangle(6,6, 2));
}
}

Loading…
Cancel
Save