public int CompareTo(object obj) { TRTriangle a1 = (TRTriangle)obj; if (this == obj || IsDoubleEquals(a1.GetArea(), GetArea())) { return(0); } return(a1.GetArea() > GetArea() ? -1 : 1); }
private static void TestInitCorrectTriangle() { try { TRTriangle t = new TRTriangle(3, 4, 5); } catch (Exception e) { Console.WriteLine("TestInitCorrectTriangle FAILED"); return; } Console.WriteLine("TestInitCorrectTriangle PASSED"); }
private static void TestAreaTriangle() { TRTriangle t = new TRTriangle(3, 4, 5); double actual = t.GetArea(); double expected = 6.0; if (IsDoubleEquals(actual, expected)) { Console.WriteLine("TestAreaTriangle PASSED"); } else { Console.WriteLine("TestAreaTriangle FAILED"); } }
private static void TestCompareEqualTriangles() { TRTriangle t1 = new TRTriangle(3, 4, 5); TRTriangle t2 = new TRTriangle(4, 3, 5); int comp = t1.CompareTo(t2); if (comp == 0) { Console.WriteLine("IsDoubleEquals PASSED"); } else { Console.WriteLine("IsDoubleEquals FAILED"); } }
private static void TestMultiplyTriangles() { TRTriangle t1 = new TRTriangle(3, 4, 5); TRTriangle expected = new TRTriangle(6, 8, 10); TRTriangle actual = t1 * 2; if (IsDoubleEquals(actual.GetA(), expected.GetA()) && IsDoubleEquals(actual.GetB(), expected.GetB()) && IsDoubleEquals(actual.GetC(), expected.GetC())) { Console.WriteLine("TestMultiplyTriangles PASSED"); } else { Console.WriteLine("TestMultiplyTriangles FAILED"); } }
public TRTriangle(TRTriangle triangle) { a = triangle.a; b = triangle.b; c = triangle.c; }