Browse Source

Version der Triangle Checker Aufgabe

master
Marie Trexler 3 years ago
parent
commit
4cc1f1fa31
2 changed files with 70 additions and 1 deletions
  1. 9
    1
      src/TriangleChecker.java
  2. 61
    0
      test/TriangleCheckerTest.java

+ 9
- 1
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) {
return TriangleType.NONE;
if(a==b && a==c){
return TriangleType.EQUILATERAL;
}
if(a<=0 || b<=0 || c<=0){
return TriangleType.NONE;
}
else{
return TriangleType.NORMAL;
}
} }





+ 61
- 0
test/TriangleCheckerTest.java View File



} }


@Test
public void testValidEquilateralTriangle() {

// 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);
}

@Test
public void testValidNoTriangle1() {

// Arrange
float a = 0;
float b = 1;
float c = 0;

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

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

}

@Test
public void testValidNoTriangle2() {

// Arrange
float a = 2;
float b = 1;
float c = -2;

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

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

}
@Test
public void testValidNoTriangle3() {

// Arrange
float a = 1;
float b = 2;
float c = 13;

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

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

}
} }

Loading…
Cancel
Save