Browse Source

added check for ISOSCELES

master
Tim Lachmann 3 weeks ago
parent
commit
ad1d3afbdd

+ 5
- 2
src/Praktikum02/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 && a + c > b && b + c > a){ if(a + b > c && a + c > b && b + c > a){
if (a == b || b == c || a == c){
return TriangleType.ISOSCELES;
}
return TriangleType.NORMAL; return TriangleType.NORMAL;
} else {
return TriangleType.NONE;
} }
return TriangleType.NONE;





} }

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

void checkTriangleNone(){ void checkTriangleNone(){
assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(6,2.9f, 2)); assertEquals(TriangleChecker.TriangleType.NONE,TriangleChecker.checkTriangle(6,2.9f, 2));
} }

@Test
void checkTriangleISOSCELES(){
assertEquals(TriangleChecker.TriangleType.ISOSCELES,TriangleChecker.checkTriangle(6,6, 2));
}
} }

Loading…
Cancel
Save