Browse Source

Test2 gleichschenklig

finished
master
Moritz Neumeier 3 years ago
parent
commit
37ece7ec9f

BIN
out/production/TriangleCheckerAssignment/TriangleChecker.class View File


BIN
out/test/TriangleCheckerAssignment/TriangleCheckerTest.class View File


+ 3
- 5
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) || c >= (b+a) || b >= (a+c) || a<=0 || b<=0 || c<=0){ if(a >= (b+c) || c >= (b+a) || b >= (a+c) || a<=0 || b<=0 || c<=0){

return TriangleType.NONE; return TriangleType.NONE;
} }

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


} }



} }

+ 18
- 0
test/TriangleCheckerTest.java View File



} }


@Test
public void testISOSCELESTriangle() {

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

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

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


}


} }

Loading…
Cancel
Save