static void Main(string[] args) { Console.Title = "Сахарова Елизавета ИУ5-32Б"; Rectangle rectangle = new Rectangle(6, 4); Square square = new Square(5); Circle circle = new Circle(7); // ArrayList Console.WriteLine("ArrayList"); ArrayList arrayList = new ArrayList(); arrayList.Add(circle); arrayList.Add(rectangle); arrayList.Add(square); foreach (var x in arrayList) { Console.WriteLine(x); } Console.WriteLine("\nОтсортированный ArrayList"); arrayList.Sort(); foreach (var x in arrayList) { Console.WriteLine(x); } // List<Figure> Console.WriteLine("\nList<Figure>"); List <Figure> figureList = new List <Figure>(); figureList.Add(circle); figureList.Add(rectangle); figureList.Add(square); foreach (var x in figureList) { Console.WriteLine(x); } Console.WriteLine("\nОтсортированный List<Figure>"); arrayList.Sort(); foreach (var x in arrayList) { Console.WriteLine(x); } // Matrix<Figure> Console.WriteLine("\nMatrix<Figure>"); Matrix <Figure> matrix = new Matrix <Figure>(2, 2, 2, square); Console.WriteLine(matrix.ToString()); // SimpleList<Figure> Console.WriteLine("SimpleList<Figure>"); SimpleList <Figure> list = new SimpleList <Figure>(); list.Add(square); list.Add(rectangle); list.Add(circle); foreach (var x in list) { Console.WriteLine(x); } Console.WriteLine("\nОтсортированный SimpleList<Figure>"); list.Sort(); foreach (var x in list) { Console.WriteLine(x); } // SimpleStack<Figure> Console.WriteLine("\nSimpleStack<Figure>"); SimpleStack <Figure> stack = new SimpleStack <Figure>(); stack.Push(rectangle); stack.Push(square); stack.Push(circle); while (stack.Count > 0) { Figure f = stack.Pop(); Console.WriteLine(f); } Console.ReadKey(); }
static void Main(string[] args) { Circle cir = new Circle(10); Rectangle rec = new Rectangle(1, 3); Square sc = new Square(2); Circle cir2 = new Circle(100); //*** Test 1: ArrayList *** ArrayList al = new ArrayList(); al.Add(cir); al.Add(rec); al.Add(sc); al.Add(cir2); Console.WriteLine("Test 1: ArrayList"); Console.WriteLine("\nДо сортировки:"); foreach (Figure f in al) { Console.WriteLine(f); } al.Sort(); Console.WriteLine("\nПосле сортировки:"); foreach (Figure f in al) { Console.WriteLine(f); } //*** Test 2: List<T> *** List <Figure> list = new List <Figure>(); list.Add(sc); list.Add(rec); list.Add(cir); list.Add(cir2); Console.WriteLine("\n\nTest 2: List<T>"); Console.WriteLine("\nДо сортировки:"); foreach (Figure f in list) { Console.WriteLine(f); } list.Sort(); Console.WriteLine("\nПосле сортировки:"); foreach (Figure f in list) { Console.WriteLine(f); } //*** Test 3: Matrix<T> *** Matrix <Figure> matrix = new Matrix <Figure>(3, 3, 3, new FigureMatrixCheckEmpty()); matrix[0, 0, 0] = rec; matrix[1, 1, 1] = sc; matrix[2, 2, 2] = cir; matrix[2, 0, 2] = cir2; Console.WriteLine("\n\nTest 3: Matrix<T>\n"); Console.WriteLine(matrix.ToString()); //*** Test 4: SimpleList<T> *** SimpleList <Figure> simple_list = new SimpleList <Figure>(); simple_list.Add(cir); simple_list.Add(rec); simple_list.Add(cir2); simple_list.Add(sc); Console.WriteLine("Test 4: SimpleList<T>"); Console.WriteLine("\nДо сортировки:"); foreach (var x in simple_list) { Console.WriteLine(x); } simple_list.Sort(); Console.WriteLine("\nПосле сортировки:"); foreach (var x in simple_list) { Console.WriteLine(x); } //*** Test 5: SimpleStack<T> *** SimpleStack <Figure> stack = new SimpleStack <Figure>(); stack.Push(rec); stack.Push(sc); stack.Push(cir2); stack.Push(cir); Console.WriteLine("\nTest 5: SimpleStack<T>\n"); while (stack.Count > 0) { Figure f = stack.Pop(); Console.WriteLine(f); } Console.ReadKey(); }
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 <Figure> fl = new List <Figure>(); 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Матрица"); Matrix <Figure> cube = new Matrix <Figure>(new FigureMatrixCheckEmpty(), 3, 3, 3); 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(); }