@Test public void testScalene(){ Classification res = TriangleClassification.classify(2, 3, 4); assertEquals(SCALENE, res); }
public static Classification classify(int a, int b, int c) { if(a <= 0 || b <= 0 || c <= 0){ return NOT_A_TRIANGLE; } if(a==b && b==c){ return EQUILATERAL; } int max = Math.max(a, Math.max(b, c)); if ((max == a && max - b - c >= 0) || (max == b && max - a - c >= 0) || (max == c && max - a - b >= 0)) { return NOT_A_TRIANGLE; } if(a==b || a==c || b==c){ return ISOSCELES; } else { return SCALENE; } }
TriangleClassification { public static Classification classify(int a, int b, int c) { if(a <= 0 || b <= 0 || c <= 0){ return NOT_A_TRIANGLE; } if(a==b && b==c){ return EQUILATERAL; } int max = Math.max(a, Math.max(b, c)); if ((max == a && max - b - c >= 0) || (max == b && max - a - c >= 0) || (max == c && max - a - b >= 0)) { return NOT_A_TRIANGLE; } if(a==b || a==c || b==c){ return ISOSCELES; } else { return SCALENE; } } }
TriangleClassification { public static Classification classify(int a, int b, int c) { if(a <= 0 || b <= 0 || c <= 0){ return NOT_A_TRIANGLE; } if(a==b && b==c){ return EQUILATERAL; } int max = Math.max(a, Math.max(b, c)); if ((max == a && max - b - c >= 0) || (max == b && max - a - c >= 0) || (max == c && max - a - b >= 0)) { return NOT_A_TRIANGLE; } if(a==b || a==c || b==c){ return ISOSCELES; } else { return SCALENE; } }  }
TriangleClassification { public static Classification classify(int a, int b, int c) { if(a <= 0 || b <= 0 || c <= 0){ return NOT_A_TRIANGLE; } if(a==b && b==c){ return EQUILATERAL; } int max = Math.max(a, Math.max(b, c)); if ((max == a && max - b - c >= 0) || (max == b && max - a - c >= 0) || (max == c && max - a - b >= 0)) { return NOT_A_TRIANGLE; } if(a==b || a==c || b==c){ return ISOSCELES; } else { return SCALENE; } }  static Classification classify(int a, int b, int c); }
TriangleClassification { public static Classification classify(int a, int b, int c) { if(a <= 0 || b <= 0 || c <= 0){ return NOT_A_TRIANGLE; } if(a==b && b==c){ return EQUILATERAL; } int max = Math.max(a, Math.max(b, c)); if ((max == a && max - b - c >= 0) || (max == b && max - a - c >= 0) || (max == c && max - a - b >= 0)) { return NOT_A_TRIANGLE; } if(a==b || a==c || b==c){ return ISOSCELES; } else { return SCALENE; } }  static Classification classify(int a, int b, int c);  }