Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var square = new Square {
                Side = 10
            };
            var adapter = new SquareToRectangleAdapter(square);
            var area    = adapter.Area();

            Console.WriteLine($"Area = {area}");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var square = new Square()
            {
                Side = 5
            };
            var adapter = new SquareToRectangleAdapter(square);

            Console.WriteLine(adapter.Area());
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Square square = new Square {
                Side = 4
            };
            IRectangle squareToRectangleAdapter = new SquareToRectangleAdapter(square);

            Console.WriteLine($"Area of square with side {square.Side}: " +
                              $"{squareToRectangleAdapter.Area()}");
        }
Exemplo n.º 4
0
        private static void Main(string[] args)
        {
            /*
             * In this adapter example we attempt to create a SquareToRectangle adapter class
             * which basically converts a Square to rectangle and then we calculate the area
             * of said rectangle with an extension helper method.
             */

            var square = new Square {
                Side = 4
            };
            var rectangle = new SquareToRectangleAdapter(square);

            WriteLine($"Area of square with {square.Side} sides is {rectangle.Area()}");
        }