Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Rectangle obj_rect   = new Rectangle(4, 6);
            Square    obj_square = new Square(4);
            Cirle     obj_circle = new Cirle(3.14);

            Console.WriteLine("\tIPRINT:");

            obj_rect.IPrint();
            obj_square.IPrint();
            obj_circle.IPrint();

            List <Figure> list_f = new List <Figure>();

            list_f.Add(obj_rect);
            list_f.Add(obj_square);
            list_f.Add(obj_circle);

            Console.WriteLine("\tNOT SORTED LIST: ");
            foreach (var obj in list_f)
            {
                Console.WriteLine(obj);
            }

            list_f.Sort();

            Console.WriteLine("\tSORTED LIST:");
            foreach (var obj in list_f)
            {
                Console.WriteLine(obj);
            }

            SimpleStack <Figure> stack_f = new SimpleStack <Figure>();

            stack_f.Add(obj_rect);
            stack_f.Add(obj_square);
            stack_f.Add(obj_circle);

            Console.WriteLine("\tSTACK");

            while (stack_f.Count > 0)
            {
                var a = stack_f.Pop();
                Console.WriteLine(a);
            }

            Console.WriteLine("\tMATRIX:");

            Matrix <Figure> matrix_f = new Matrix <Figure>(3, 3, 3, new FigureMatrixCheckEmpty());

            matrix_f[0, 0, 0] = obj_rect;
            matrix_f[1, 1, 1] = obj_square;
            matrix_f[2, 2, 2] = obj_circle;

            Console.WriteLine(matrix_f.ToString());

            Console.Write("\n\nEnter any key for continue...");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            Matrix <Figure> matrix = new Matrix <Figure>(3, 3, 3, new FigureMatrixCheckEmpty());
            Rectangle       rect   = new Rectangle(5, 4);
            Square          square = new Square(5);
            Circle          cir    = new Circle(5);

            rect.Print();
            square.Print();
            cir.Print();
            List <Figure> fl = new List <Figure>();

            fl.Add(cir);
            fl.Add(rect);
            fl.Add(square);
            Console.WriteLine("Before sort");
            foreach (var x in fl)
            {
                Console.WriteLine(x);
            }
            fl.Sort();
            Console.WriteLine("After sort");
            foreach (var x in fl)
            {
                Console.WriteLine(x);
            }
            matrix[0, 0, 0] = rect;
            matrix[1, 1, 1] = square;
            matrix[2, 2, 2] = cir;
            Console.WriteLine(matrix.ToString());
            SimpleStack <Figure> stack = new SimpleStack <Figure>();

            stack.Push(rect);
            stack.Push(square);
            stack.Push(cir);
            while (stack.Count > 0)
            {
                Figure f = stack.Pop();
                Console.WriteLine(f);
            }
            Console.ReadKey();
        }