Browse Source

Version 3 der Triangle Checker Aufgabe

master
Marie Trexler 2 years ago
parent
commit
3a0ebd83e7
2 changed files with 26 additions and 10 deletions
  1. 1
    1
      src/TriangleChecker.java
  2. 25
    9
      test/TriangleCheckerTest.java

+ 1
- 1
src/TriangleChecker.java View File

@@ -47,7 +47,7 @@ public class TriangleChecker {

// Analyse der Dreiecksart
public static TriangleType checkTriangle(float a, float b, float c) {
if(a<=0 || b<=0 || c<=0 || a+b<c|| a+c<b || b+c<a){
if(a<=0 || b<=0 || c<=0 || a+b<=c|| a+c<=b || b+c<=a){
return TriangleType.NONE;
}
if(a==b && a==c){

+ 25
- 9
test/TriangleCheckerTest.java View File

@@ -98,28 +98,28 @@ public class TriangleCheckerTest {
}

@Test
public void testValidIsoscelesTriangle() {
public void testValidNoTriangle5() {

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

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

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

}

@Test
public void testValidNoTriangle5() {
public void testValidNoTriangle6() {

// Arrange
float a = 4;
float b = 4;
float c = 13;
float a = 3;
float b = 5;
float c = 8;

// Act
TriangleChecker.TriangleType type = TriangleChecker.checkTriangle(a, b, c);
@@ -129,5 +129,21 @@ public class TriangleCheckerTest {

}

@Test
public void testValidIsoscelesTriangle() {

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

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

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

}


}

Loading…
Cancel
Save