Browse Source

Normale Dreiecke und Gleichseitige Dreiecke

master
Mikko Winkler 2 years ago
parent
commit
73650835d6
2 changed files with 22 additions and 0 deletions
  1. 7
    0
      src/TriangleChecker.java
  2. 15
    0
      test/TriangleCheckerTest.java

+ 7
- 0
src/TriangleChecker.java View File

@@ -47,6 +47,13 @@ public class TriangleChecker {

// Analyse der Dreiecksart
public static TriangleType checkTriangle(float a, float b, float c) {

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


return TriangleType.NONE;
}


+ 15
- 0
test/TriangleCheckerTest.java View File

@@ -16,7 +16,22 @@ public class TriangleCheckerTest {

// Assert
assertEquals(TriangleChecker.TriangleType.NORMAL, type);
}

@Test
public void testEqualTriangle(){
// Arrange
float a = 3;
float b = 3;
float c = 3;

// Act
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);

// Assert
assertEquals(TriangleChecker.TriangleType.ISOSCELES, type);
}



}

Loading…
Cancel
Save