コード例 #1
0
        static void Main(string[] args)
        {
            Console.Title = "Терентьев Владислав ИУ5-33";
            Rectangle rectangle = new Rectangle(5, 4);
            Square    square    = new Square(5);
            Circle    circle    = new Circle(5);

            Console.WriteLine("ArrayList");
            ArrayList collection = new ArrayList();

            collection.Add(circle);
            collection.Add(rectangle);
            collection.Add(square);
            foreach (object o in collection)
            {
                Console.WriteLine(o);
            }

            Console.WriteLine("\nList<GeomFigure>");
            List <GeomFigure> coll2 = new List <GeomFigure>();

            coll2.Add(circle);
            coll2.Add(rectangle);
            coll2.Add(square);
            foreach (object o in coll2)
            {
                Console.WriteLine(o);
            }
            Console.WriteLine("\nList<GeomFigure> - сортировка");
            coll2.Sort();
            foreach (object o in coll2)
            {
                Console.WriteLine(o);
            }

            //
            Console.WriteLine("\nМатрица");
            Matrix3D <GeomFigure> cube = new Matrix3D <GeomFigure>(3, 3, 3, null);

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

            Console.WriteLine("\nСписок");
            SimpleList <GeomFigure> list = new SimpleList <GeomFigure>();

            list.Add(square);
            list.Add(rectangle);
            list.Add(circle);
            foreach (var o in list)
            {
                Console.WriteLine(o);
            }
            list.Sort();
            Console.WriteLine("\nСортировка списка");
            foreach (var o in list)
            {
                Console.WriteLine(o);
            }

            Console.WriteLine("\nСтек");
            SimpleStack <GeomFigure> stack = new SimpleStack <GeomFigure>();

            stack.Push(rectangle);
            stack.Push(square);
            stack.Push(circle);
            while (stack.Count > 0)
            {
                GeomFigure tmp = stack.Pop();
                Console.WriteLine(tmp);
            }
            Console.ReadKey();
        }