static void Main(string[] args) { Rectangle rectangle = new Rectangle(2, 5); Square square = new Square(4); Circle circle = new Circle(4); System.Console.WriteLine("\nArrayList"); ArrayList arrayList = new ArrayList(); arrayList.Add(circle); arrayList.Add(rectangle); arrayList.Add(square); foreach (GeomFigure o in arrayList) { Console.WriteLine(o.ToString()); } System.Console.WriteLine("\nСорт.ArrayList"); arrayList.Sort(); foreach (GeomFigure o in arrayList) { Console.WriteLine(o.ToString()); } System.Console.WriteLine("\nЛист"); List <GeomFigure> FiguresList = new List <GeomFigure>(); FiguresList.Add(circle); FiguresList.Add(rectangle); FiguresList.Add(square); foreach (GeomFigure o in FiguresList) { Console.WriteLine(o.ToString()); } System.Console.WriteLine("\nСорт.Лист"); FiguresList.Sort(); foreach (GeomFigure o in FiguresList) { Console.WriteLine(o.ToString()); } System.Console.WriteLine("\nМатрица"); Matrix <GeomFigure> matrix = new Matrix <GeomFigure>(3, 3, 3, new GeomFigureMatrixCheckEmpty()); matrix[0, 0, 0] = rectangle; matrix[1, 1, 1] = square; matrix[2, 2, 2] = circle; System.Console.WriteLine(matrix.ToString()); System.Console.WriteLine("\nSimpleList"); SimpleList <GeomFigure> simpleList = new SimpleList <GeomFigure>(); simpleList.Add(circle); simpleList.Add(rectangle); simpleList.Add(square); foreach (var x in simpleList) { System.Console.WriteLine(x); } System.Console.WriteLine("\nСорт.SimpleList"); simpleList.Sort(); foreach (var x in simpleList) { System.Console.WriteLine(x); } System.Console.WriteLine("\nSimpleStack"); SimpleStack <GeomFigure> simplestack = new SimpleStack <GeomFigure>(); simplestack.push(circle); simplestack.push(rectangle); simplestack.push(square); foreach (var x in simplestack) { System.Console.WriteLine(x); } System.Console.WriteLine("\nSimpleStack popping out"); while (simplestack.Count > 0) { GeomFigure f = simplestack.pop(); Console.WriteLine(f); } }
static void Main(string[] args) { Rect rect = new Rect(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 (object x in al) { Console.WriteLine(x); } Console.WriteLine("\nArrayList - сортировка"); al.Sort(); foreach (object x in al) { Console.WriteLine(x); } Console.WriteLine("\nList<GeometricFigure>"); List <Figure> fl = new List <Figure>(); fl.Add(circle); fl.Add(rect); fl.Add(square); foreach (Figure x in fl) { Console.WriteLine(x); } Console.WriteLine("\nList<GeometricFigure> - сортировка"); fl.Sort(); foreach (Figure x in fl) { Console.WriteLine(x); } Console.WriteLine("\nМатрица"); Matrix <Figure> cube = new Matrix <Figure>(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 <Figure> list = new SimpleList <Figure>(); 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 <Figure> stack = new SimpleStack <Figure>(); stack.Push(rect); stack.Push(square); stack.Push(circle); while (stack.Count > 0) { Figure f = stack.Pop(); Console.WriteLine(f); } Console.ReadLine(); }