Exemple #1
0
        public int CompareTo(object obj)
        {
            TRTriangle a1 = (TRTriangle)obj;

            if (this == obj || IsDoubleEquals(a1.GetArea(), GetArea()))
            {
                return(0);
            }

            return(a1.GetArea() > GetArea() ? -1 : 1);
        }
Exemple #2
0
        private static void TestInitCorrectTriangle()
        {
            try
            {
                TRTriangle t = new TRTriangle(3, 4, 5);
            }
            catch (Exception e)
            {
                Console.WriteLine("TestInitCorrectTriangle FAILED");
                return;
            }

            Console.WriteLine("TestInitCorrectTriangle PASSED");
        }
Exemple #3
0
        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");
            }
        }
Exemple #4
0
        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");
            }
        }
Exemple #5
0
        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");
            }
        }
Exemple #6
0
 public TRTriangle(TRTriangle triangle)
 {
     a = triangle.a;
     b = triangle.b;
     c = triangle.c;
 }