Exemple #1
0
        public List <Function> DeepCopy()
        {
            List <Function> someSeries2 = new List <Function>();

            foreach (Function element in someSeries)
            {
                if (element is Ellipse)
                {
                    Ellipse equation = new Ellipse(element.A, element.B);
                    someSeries2.Add(equation);
                }
                if (element is Hiperbola)
                {
                    Hiperbola equation = new Hiperbola(element.A, element.B);
                    someSeries2.Add(equation);
                }
                if (element is Parabola)
                {
                    Parabola equation = new Parabola(element.A, element.B, element.C);
                    someSeries2.Add(equation);
                }
            }

            return(someSeries2);
        }
Exemple #2
0
        public static void Test(Series ser)
        {
            Ellipse   equation  = new Ellipse(10, 8);
            Hiperbola equation2 = new Hiperbola(1, 2);
            Parabola  equation3 = new Parabola(5, -2, 7);

            if (equation.Equals(new Ellipse(10, 8)) && equation2.Equals(new Hiperbola(1, 2)) && equation3.Equals(new Parabola(5, -2, 7)))
            {
                Console.WriteLine("Equals is correct");
            }
            else
            {
                Console.WriteLine("Equals is not correct");
            }

            Hiperbola equation4 = new Hiperbola(1, 2);
            Ellipse   equation5 = new Ellipse(10, 8);
            Parabola  equation6 = new Parabola(5, -2, 7);

            if (equation == equation5 && equation2 == equation4 && equation3 == equation6)
            {
                Console.WriteLine("== and != is correct");
            }
            else
            {
                Console.WriteLine("== and != is not correct");
            }

            if (equation.GetHashCode() == equation5.GetHashCode())
            {
                Console.WriteLine("GetHashCode is correct");
            }
            else
            {
                Console.WriteLine("GetHashCode is not correct");
            }

            Console.WriteLine("\n" + "Тест DeepCopy: " + "\n");

            List <Function> someSeries2 = new List <Function>();

            someSeries2 = ser.DeepCopy();
            foreach (Function element in someSeries2)
            {
                element.ToString(2);
            }
            Console.Write("\n" + "Нажмите любую кнопку...");
            Console.ReadKey();
        }