|
|
@@ -1,10 +1,10 @@ |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
public class TriangleChecker { |
|
|
|
|
|
|
|
|
|
|
|
public enum TriangleType { |
|
|
|
NONE, |
|
|
|
NORMAL, |
|
|
|
NONE, // kein Dreieck |
|
|
|
NORMAL, // Dreieck |
|
|
|
ISOSCELES, // Gleichschenklig |
|
|
|
EQUILATERAL // Gleichseitig |
|
|
|
} |
|
|
@@ -32,23 +32,49 @@ 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 |
|
|
|
// Analysen |
|
|
|
public static TriangleType checkTriangle(float a, float b, float c) { |
|
|
|
if(checkIfNotValid(a,b,c)) return TriangleType.NONE; |
|
|
|
if(checkIfEquilateral(a,b,c)) return TriangleType.EQUILATERAL; |
|
|
|
if(checkIfIsosceles(a,b,c)) return TriangleType.ISOSCELES; |
|
|
|
if(checkIfNormal(a,b,c)) return TriangleType.NORMAL; |
|
|
|
return TriangleType.NONE; |
|
|
|
} |
|
|
|
|
|
|
|
// Analyse kein Dreieck |
|
|
|
private static boolean checkIfNotValid(float a, float b, float c){ |
|
|
|
if (a + b <= c || a + c <= b || b + c <= a) return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// Analyse normales Dreieck |
|
|
|
private static boolean checkIfNormal(float a, float b, float c){ |
|
|
|
if (a != b && b != c && a != c) return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// Analyse gleichschenkliges Dreieck |
|
|
|
private static boolean checkIfIsosceles(float a, float b, float c){ |
|
|
|
if (a == b || a == c || b == c) return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// Analyse gleichseitiges Dreieck |
|
|
|
private static boolean checkIfEquilateral(float a, float b, float c){ |
|
|
|
if (a == b && b == c) return true; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |