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(); }
static void Main(string[] args) { Rectangle rect = new Rectangle(2, 2); Square square = new Square(5); Circle circle = new Circle(5); ArrayList fl = new ArrayList(); fl.Add(circle); fl.Add(square); fl.Add(rect); fl.Sort(); List <Geom_fig> f2 = new List <Geom_fig> { circle, rect, square }; Console.WriteLine("\nПеред сортировкой:"); foreach (var x in fl) { Console.WriteLine(x); } //сортировка fl.Sort(); Console.WriteLine("\nПосле сортировки:"); foreach (var x in fl) { Console.WriteLine(x); } Console.WriteLine("\nМатрица"); Matrix <Geom_fig> matrix = new Matrix <Geom_fig>(3, 3, new FigureMatrixCheckEmpty()); matrix[0, 0] = rect; matrix[1, 1] = square; matrix[2, 2] = circle; Console.WriteLine(matrix.ToString()); SimpleList <Geom_fig> list = new SimpleList <Geom_fig>(); list.Add(circle); list.Add(rect); list.Add(square); Console.WriteLine("\nПеред сортировкой:"); foreach (var x in list) { Console.WriteLine(x); } //сортировка list.Sort(); Console.WriteLine("\nПосле сортировки:"); foreach (var x in list) { Console.WriteLine(x); } Console.ReadLine(); }