コード例 #1
0
        private static void TestInitIncorrectPyramid()
        {
            try
            {
                TRPiramid t = new TRPiramid(10, 2, 3, -10);
            }
            catch (Exception e)
            {
                Console.WriteLine("TestInitIncorrectPyramid PASSED");
                return;
            }

            Console.WriteLine("TestInitIncorrectPyramid FAILED");
        }
コード例 #2
0
        private static void TestPyramidArea()
        {
            TRPiramid t        = new TRPiramid(3, 4, 5, 10);
            double    actual   = t.GetArea();
            double    expected = 19.9999;

            if (IsDoubleEquals(actual, expected))
            {
                Console.WriteLine("TestPyramidArea PASSED");
            }
            else
            {
                Console.WriteLine("TestPyramidArea FAILED");
            }
        }
コード例 #3
0
        private static void TestDifferenceInHashSet()
        {
            TRPiramid           t1  = new TRPiramid(3, 4, 5, 1);
            TRPiramid           t2  = new TRPiramid(3, 4, 5, 2);
            HashSet <TRPiramid> set = new HashSet <TRPiramid>();

            set.Add(t1);
            set.Add(t2);

            if (set.Count == 1)
            {
                Console.WriteLine("TestDifferenceInHashSet FAILED");
            }
            else
            {
                Console.WriteLine("TestDifferenceInHashSet PASSED");
            }
        }
コード例 #4
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            TRPiramid p = (TRPiramid)obj;

            if (IsDoubleEquals(a, p.a) &&
                IsDoubleEquals(b, p.b) &&
                IsDoubleEquals(c, p.c) &&
                IsDoubleEquals(h, p.h))
            {
                return(true);
            }

            return(false);
        }