Browse Source

all checks okay

master
Tim Lachmann 3 weeks ago
parent
commit
f3b27c5a7a
2 changed files with 34 additions and 0 deletions
  1. 3
    0
      src/Praktikum02/TriangleChecker.java
  2. 31
    0
      test/Praktikum02/TriangleCheckerTest.java

+ 3
- 0
src/Praktikum02/TriangleChecker.java View File

@@ -51,6 +51,9 @@ 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){
return TriangleType.EQUILATERAL;
}
if (a == b || b == c || a == c){
return TriangleType.ISOSCELES;
}

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

@@ -20,4 +20,35 @@ class TriangleCheckerTest {
void checkTriangleISOSCELES(){
assertEquals(TriangleChecker.TriangleType.ISOSCELES,TriangleChecker.checkTriangle(6,6, 2));
}

@Test
void checkTriangleEQUILATERAL(){
assertEquals(TriangleChecker.TriangleType.EQUILATERAL,TriangleChecker.checkTriangle(6,6, 6));
}

@Test
void checkTriangleANegativ(){
assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(-6,6, 6));
}
@Test
void checkTriangleBNegativ(){
assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(6,-6, 6));
}
@Test
void checkTriangleCNegativ(){
assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(6,6, -6));
}

@Test
void checkTriangleAToLong(){
assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(36,6, 6));
}
@Test
void checkTriangleBToLong(){
assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(6,46, 6));
}
@Test
void checkTriangleCToLong(){
assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(6,6, 56));
}
}

Loading…
Cancel
Save