|
|
@@ -1,9 +1,9 @@ |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
public class TriangleChecker { |
|
|
|
|
|
|
|
|
|
|
|
public enum TriangleType { |
|
|
|
NONE, |
|
|
|
NONE, |
|
|
|
NORMAL, |
|
|
|
ISOSCELES, // Gleichschenklig |
|
|
|
EQUILATERAL // Gleichseitig |
|
|
@@ -32,23 +32,34 @@ public class TriangleChecker { |
|
|
|
switch (type) { |
|
|
|
case NONE: |
|
|
|
System.out.println("Kein Dreieck"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case NORMAL: |
|
|
|
System.out.println("Dreieck"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case ISOSCELES: |
|
|
|
System.out.println("Gleichschenkliges Dreieck"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case EQUILATERAL: |
|
|
|
System.out.println("Gleichseitiges Dreieck"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Analyse der Dreiecksart |
|
|
|
public static TriangleType checkTriangle(float a, float b, float c) { |
|
|
|
if (triangleTheorem(a,b,c) ){ |
|
|
|
if(a==b && a==c){return TriangleType.EQUILATERAL;} |
|
|
|
if(a==b||b==c||a==c){return TriangleType.ISOSCELES;} |
|
|
|
|
|
|
|
return TriangleType.NORMAL; |
|
|
|
} |
|
|
|
return TriangleType.NONE; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean triangleTheorem(float a, float b, float c) { |
|
|
|
if (a <= 0 || b <= 0 || c <= 0) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return (a + b > c && b + c > a && a + c > b); |
|
|
|
} |
|
|
|
} |