static void Main(string[] args) { Console.Title = "Аникин Филипп, ИУ5-33Б"; Rectangle rect = new Rectangle(8, 6); Square sq = new Square(8); Circle cir = new Circle(8); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nArrayList"); Console.ResetColor(); ArrayList list = new ArrayList(); list.Add(rect); list.Add(sq); list.Add(cir); foreach (var i in list) { Console.WriteLine(i.ToString()); } List <Geometric_figure> list2 = new List <Geometric_figure>(); list2.Add(rect); list2.Add(cir); list2.Add(sq); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\nПеред сортировкой:"); Console.ResetColor(); foreach (var i in list2) { Console.Write(i.ToString() + " \n"); } list2.Sort(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("\nПосле сортировки:"); Console.ResetColor(); foreach (var i in list2) { Console.Write(i.ToString() + " \n"); } Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("\nМатрица"); Console.ResetColor(); Matrix <Geometric_figure> matrix = new Matrix <Geometric_figure>(3, 3, 3, new FigureMatrixCheckEmpty()); matrix[0, 0, 0] = rect; matrix[1, 1, 1] = sq; matrix[2, 2, 2] = cir; Console.WriteLine(matrix.ToString()); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("\nСтек"); Console.ResetColor(); SimpleStack <Geometric_figure> stack = new SimpleStack <Geometric_figure>(); stack.Push(rect); stack.Push(sq); stack.Push(cir); while (stack.Count > 0) { Geometric_figure f = stack.Pop(); Console.WriteLine(f); } Console.WriteLine(); Console.Write("Нажмите любую клавишу для завершения..."); Console.ReadKey(); }
static void Main(string[] args) { // ArrayList example Console.WriteLine("ArrayList:"); var arrayList = new ArrayList { new Rectangle(5, 6.3), new Rectangle(6, 3.6), new Rectangle(9.1, 4.7), new Square(6.5), new Square(3.9), new Square(5.87), new Circle(2.3), new Circle(4.2), new Circle(6.543) }; arrayList.Sort(); foreach (Figure figure in arrayList) { figure.Print(); } // Figure List example Console.WriteLine("\nFigure List:"); var figureList = new List <Figure> { new Rectangle(5, 6.3), new Rectangle(6, 3.6), new Rectangle(9.1, 4.7), new Square(6.5), new Square(3.9), new Square(5.87), new Circle(2.3), new Circle(4.2), new Circle(6.543) }; figureList.Sort(); foreach (var figure in figureList) { figure.Print(); } // Figure Matrix example Console.WriteLine("\nMatrix:"); var matrix = new Matrix <Figure>(5, 5, 4, new FigureMatrixCheckEmpty()); matrix[0, 0, 0] = figureList[0]; matrix[0, 3, 2] = figureList[1]; matrix[3, 3, 0] = figureList[2]; matrix[2, 2, 2] = figureList[3]; Console.WriteLine(matrix); // Simple Stack example Console.WriteLine("\nSimple Stack:"); var figureStack = new SimpleStack <Figure>(); foreach (var figure in figureList) { figureStack.Push(figure); } while (!figureStack.Empty()) { Console.WriteLine(figureStack.Pop()); } }