Exemplo n.º 1
0
        public static void Test()
        {
            Duck duck = new MallardDuck();

            Turkey turkey        = new WildTurkey();
            Duck   turkeyAdapter = new TurkeyAdapter(turkey);

            Console.WriteLine("The Turkey says...");
            turkey.gobble();
            turkey.fly();

            Console.WriteLine("\nThe Duck says...");
            testDuck(duck);

            Console.WriteLine("\nThe TurkeyAdapter says...");
            testDuck(turkeyAdapter);
        }
        private static void AdapterPattern()
        {
            AdapterPattern.MallardDuck duck = new AdapterPattern.MallardDuck();

            WildTurkey turkey = new WildTurkey();

            AdapterPattern.Duck turkeyAdapter = new TurkeyAdapter(turkey);

            Console.WriteLine("The Turkey says...");
            turkey.gobble();
            turkey.fly();

            Console.WriteLine("\nThe Duck says...");
            testDuck(duck);

            Console.WriteLine("\nThe TurkeyAdapter says...");
            testDuck(turkeyAdapter);
        }