Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Rectangle rect   = new Rectangle(3, 4);
            Square    square = new Square(5);
            Circle    circle = new Circle(10);

            rect.Print();
            square.Print();
            circle.Print();

            ///////////////////////////////////////////////////////////
            Console.WriteLine("\nArrayList");
            ArrayList al = new ArrayList();

            al.Add(circle);
            al.Add(rect);
            al.Add(square);

            al.Sort();
            foreach (var x in al)
            {
                Console.WriteLine(x);
            }
            //////////////////////////////////////////////////////////
            Console.WriteLine("\nList<Figure>");
            List <Figure> fl = new List <Figure>();

            fl.Add(circle);
            fl.Add(rect);
            fl.Add(square);

            fl.Sort();
            foreach (var x in fl)
            {
                Console.WriteLine(x);
            }
            //////////////////////////////////////////////////////////
            Console.WriteLine("\nМатрица");
            Matrix <double> cube = new Matrix <double>(3, 3, 3, 0);

            cube[0, 0, 0] = rect.Area();
            cube[1, 1, 1] = square.Area();
            cube[2, 2, 2] = circle.Area();
            Console.WriteLine(cube.ToString());

            //////////////////////////////////////////////////////////
            Console.WriteLine("\nСтек");
            Stack <Figure> stack = new Stack <Figure>();

            stack.Push(rect);
            stack.Push(square);
            stack.Push(circle);

            while (stack.Count > 0)
            {
                Figure f = stack.Pop();
                Console.WriteLine(f);
            }

            Console.ReadLine();
        }