Browse Source

Gleichschenklige Dreiecke werden erkannt

master
Mikko Winkler 2 years ago
parent
commit
6244920b66
2 changed files with 18 additions and 4 deletions
  1. 4
    2
      src/TriangleChecker.java
  2. 14
    2
      test/TriangleCheckerTest.java

+ 4
- 2
src/TriangleChecker.java View File

@@ -49,11 +49,13 @@ public class TriangleChecker {
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;
if(a==b || b==c|| a==c) {
if (a == b && b == c && a == c) return TriangleType.EQUILATERAL;
return TriangleType.ISOSCELES;
}
return TriangleType.NORMAL;
}


return TriangleType.NONE;
}


+ 14
- 2
test/TriangleCheckerTest.java View File

@@ -19,11 +19,11 @@ public class TriangleCheckerTest {
}

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

// Act
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);
@@ -32,6 +32,18 @@ public class TriangleCheckerTest {
assertEquals(TriangleChecker.TriangleType.ISOSCELES, 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.EQUILATERAL, type);
}

}

Loading…
Cancel
Save