2
0

kleine Verbesserungen

This commit is contained in:
Johannes Theiner 2020-04-22 19:10:54 +02:00
parent 453c238d22
commit b03b293ffe
3 changed files with 8 additions and 1 deletions

View File

@ -8,7 +8,7 @@ package de.hsel.sqs;
public class TriangleChecker {
public static TriangleType checkTriangle(int a, int b, int c) {
if (a < 0 || b < 0 || c < 0)
if (a <= 0 || b <= 0 || c <= 0)
return TriangleType.NO_TRIANGLE;
if (a == b && a == c)

View File

@ -13,6 +13,7 @@ public class TriangleTest {
@Test
public void noTriangle() {
TriangleChecker tc = new TriangleChecker();
assertEquals(TriangleChecker.checkTriangle(8, 2, 3), TriangleType.NO_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(2, 8, 3), TriangleType.NO_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(2, 3, 8), TriangleType.NO_TRIANGLE);
@ -21,11 +22,13 @@ public class TriangleTest {
@Test
public void equilateralTriangle() {
TriangleChecker tc = new TriangleChecker();
assertEquals(TriangleChecker.checkTriangle(5, 5, 5), TriangleType.EQUILATERAL_TRIANGLE);
}
@Test
public void isocelessTriangle() {
TriangleChecker tc = new TriangleChecker();
assertEquals(TriangleChecker.checkTriangle(7, 7, 2), TriangleType.ISOSCELESS_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(6, 10, 10), TriangleType.ISOSCELESS_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(4, 3, 4), TriangleType.ISOSCELESS_TRIANGLE);
@ -33,6 +36,7 @@ public class TriangleTest {
@Test
public void scaleneTriangle() {
TriangleChecker tc = new TriangleChecker();
assertEquals(TriangleChecker.checkTriangle(5, 7, 9), TriangleType.SCALENE_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(3, 5, 4), TriangleType.SCALENE_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(7, 15, 10), TriangleType.SCALENE_TRIANGLE);

View File

@ -13,6 +13,7 @@ public class WhiteboxTest {
@Test
public void instruction() {
TriangleChecker tc = new TriangleChecker();
assertEquals(TriangleChecker.checkTriangle(-1, 2, 5), TriangleType.NO_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(5, 5, 5), TriangleType.EQUILATERAL_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(3, 3, 4), TriangleType.ISOSCELESS_TRIANGLE);
@ -21,6 +22,7 @@ public class WhiteboxTest {
@Test
public void branch() {
TriangleChecker tc = new TriangleChecker();
assertEquals(TriangleChecker.checkTriangle(-1, 5, 3), TriangleType.NO_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(5, 5, 5), TriangleType.EQUILATERAL_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(2, 2, 5), TriangleType.ISOSCELESS_TRIANGLE);
@ -30,6 +32,7 @@ public class WhiteboxTest {
@Test
public void defined() {
TriangleChecker tc = new TriangleChecker();
assertEquals(TriangleChecker.checkTriangle(-1, 5, 3), TriangleType.NO_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(5, 5, 5), TriangleType.EQUILATERAL_TRIANGLE);
assertEquals(TriangleChecker.checkTriangle(2, 2, 5), TriangleType.ISOSCELESS_TRIANGLE);