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



// Analyse der Dreiecksart // Analyse der Dreiecksart
public static TriangleType checkTriangle(float a, float b, float c) { 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; return TriangleType.NONE;
} }



+ 15
- 0
test/TriangleCheckerTest.java View File



// Assert // Assert
assertEquals(TriangleChecker.TriangleType.NORMAL, type); 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