Browse Source

"Gleichschenklig" eingefügt und positiver Test

master
Sarah Baumann 2 years ago
parent
commit
f18a61ac58
2 changed files with 7 additions and 3 deletions
  1. 5
    1
      src/TriangleChecker.java
  2. 2
    2
      test/TriangleCheckerTest.java

+ 5
- 1
src/TriangleChecker.java View File

public static TriangleType checkTriangle(float a, float b, float c) { public static TriangleType checkTriangle(float a, float b, float c) {


if (a+b>c || b+c>a || a+c>b) { if (a+b>c || b+c>a || a+c>b) {

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

+ 2
- 2
test/TriangleCheckerTest.java View File



// Arrange // Arrange
float a = 2; float a = 2;
float b = 3;
float b = 2;
float c = 4; float c = 4;


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


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


} }



Loading…
Cancel
Save