|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.Scanner; |
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
|
public class TriangleChecker { |
|
|
public class TriangleChecker { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum TriangleType { |
|
|
public enum TriangleType { |
|
|
NONE, |
|
|
|
|
|
|
|
|
NONE, |
|
|
NORMAL, |
|
|
NORMAL, |
|
|
ISOSCELES, // Gleichschenklig |
|
|
ISOSCELES, // Gleichschenklig |
|
|
EQUILATERAL // Gleichseitig |
|
|
EQUILATERAL // Gleichseitig |
|
|
|
|
|
|
|
|
switch (type) { |
|
|
switch (type) { |
|
|
case NONE: |
|
|
case NONE: |
|
|
System.out.println("Kein Dreieck"); |
|
|
System.out.println("Kein Dreieck"); |
|
|
break; |
|
|
|
|
|
|
|
|
break; |
|
|
case NORMAL: |
|
|
case NORMAL: |
|
|
System.out.println("Dreieck"); |
|
|
System.out.println("Dreieck"); |
|
|
break; |
|
|
|
|
|
|
|
|
break; |
|
|
case ISOSCELES: |
|
|
case ISOSCELES: |
|
|
System.out.println("Gleichschenkliges Dreieck"); |
|
|
System.out.println("Gleichschenkliges Dreieck"); |
|
|
break; |
|
|
|
|
|
|
|
|
break; |
|
|
case EQUILATERAL: |
|
|
case EQUILATERAL: |
|
|
System.out.println("Gleichseitiges Dreieck"); |
|
|
System.out.println("Gleichseitiges Dreieck"); |
|
|
break; |
|
|
|
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 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) { |
|
|
|
|
|
//find Hypotenuse |
|
|
|
|
|
float[] tmp = {a, b, c}; |
|
|
|
|
|
Arrays.sort(tmp); |
|
|
|
|
|
float hypo = tmp[2]; |
|
|
|
|
|
float a1 = tmp[0]; |
|
|
|
|
|
float b1 = tmp[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//normal |
|
|
|
|
|
if (a1 + b1 > hypo) { |
|
|
|
|
|
|
|
|
|
|
|
//gleichseitig |
|
|
|
|
|
if (a1 + b1 + hypo == 3 * a1) |
|
|
|
|
|
return TriangleType.EQUILATERAL; |
|
|
|
|
|
|
|
|
|
|
|
//gleichschenklig |
|
|
|
|
|
if (a1 == b1 || b1 == hypo || a1 == hypo) |
|
|
|
|
|
return TriangleType.ISOSCELES; |
|
|
|
|
|
|
|
|
|
|
|
return TriangleType.NORMAL; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
return TriangleType.NONE; |
|
|
return TriangleType.NONE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |