Пример #1
0
        static void Main(string[] args)
        {
            Rectangle rect   = new Rectangle(5, 4);
            Square    square = new Square(5);
            Circle    circle = new Circle(5);

            Console.WriteLine("\nArrayList");

            ArrayList al = new ArrayList();

            al.Add(circle);
            al.Add(rect);
            al.Add(square);
            foreach (var x in al)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("\nArrayList - сортировка");
            al.Sort();
            foreach (var x in al)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("\nList<Figure>");

            List <GeomFigure> fl = new List <GeomFigure>();

            fl.Add(circle);
            fl.Add(rect);
            fl.Add(square);
            foreach (var x in fl)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("\nList<Figure> - сортировка");
            fl.Sort();
            foreach (var x in fl)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("\nМатрица");

            Matrix3D <GeomFigure> cube = new Matrix3D <GeomFigure>(3, 3, 3, null);

            cube[0, 0, 0] = rect;
            cube[1, 1, 1] = square;
            cube[2, 2, 2] = circle;
            Console.WriteLine(cube.ToString());
            Console.WriteLine("\nСписок");

            SimpleList <GeomFigure> list = new SimpleList <GeomFigure>();

            list.Add(square);
            list.Add(rect);
            list.Add(circle);
            foreach (var x in list)
            {
                Console.WriteLine(x);
            }
            list.Sort();
            Console.WriteLine("\nСортировка списка");
            foreach (var x in list)
            {
                Console.WriteLine(x);
            }
            Console.WriteLine("\nСтек");
            SimpleStack <GeomFigure> stack = new SimpleStack <GeomFigure>();

            stack.Push(rect);
            stack.Push(square);
            stack.Push(circle);
            while (stack.Count > 0)
            {
                GeomFigure f = stack.Pop();
                Console.WriteLine(f);
            }

            Console.ReadKey();
        }
Пример #2
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();
        }