static void Main(string[] args)
        {
            Square square = new Square {
                Side = 10
            };

            IRectangle rec = new SquareToRectangleAdapter(square);
        }
        static void Main(string[] args)
        {
            var square = new Square {
                Side = 10
            };
            var adapter = new SquareToRectangleAdapter(square);
            var area    = adapter.Area();

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

            Console.WriteLine(adapter.Area());
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            var square = new Square()
            {
                Side = 4
            };
            var rect = new SquareToRectangleAdapter(square);

            Console.WriteLine($"{rect.Height}, {rect.Width}");
        }
Exemple #5
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()}");
        }
        public void TestCase()
        {
            var square = new Square()
            {
                Side = 4
            };
            var rect = new SquareToRectangleAdapter(square);

            Assert.That(rect.Width, Is.EqualTo(4));
            Assert.That(rect.Height, Is.EqualTo(4));
        }
        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()}");
        }