Example #1
0
        static void Main(string[] args)
        {
            MallardDuck mallardDuck   = new MallardDuck();
            WildTurkey  wildTurkey    = new WildTurkey();
            Duck        turkeyAdapter = new TurkeyAdapter(wildTurkey);

            turkeyAdapter.Fly();
            turkeyAdapter.Quack();
        }
Example #2
0
        private static void TurkeyTestDrive()
        {
            IDuck   duck        = new MallardDuck();
            ITurkey duckAdapter = new DuckAdapter(duck);

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("The DuckAdapter says...");
                duckAdapter.Gobble();
                duckAdapter.Fly();
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            var turkey = new WildTurkey();
            var duck   = new MallardDuck();

            var ducks = new List <IDuck>
            {
                duck,
                new DuckAdapter(turkey)
            };

            Run(ducks);

            Console.Read();
        }
Example #4
0
        private static void Main()
        {
            var duck          = new MallardDuck();
            var turkey        = new WildTurkey();
            var 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);
        }
Example #5
0
        static void Main(string[] args)
        {
            MallardDuck duck          = new MallardDuck();
            WildTurkey  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);
        }
Example #6
0
        void simulate()
        {
            IQuackable mallardDuck = new MallardDuck();
            IQuackable redheadDuck = new RedheadDuck();
            IQuackable duckCall    = new DuckCall();
            IQuackable rubberDuck  = new RubberDuck();
            IQuackable gooseDuck   = new GooseAdapter(new Goose());

            Console.WriteLine("Duck Simulator : With Goose Adapter");

            simulate(mallardDuck);
            simulate(redheadDuck);
            simulate(duckCall);
            simulate(rubberDuck);
            simulate(gooseDuck);
        }
Example #7
0
        static void Main()
        {
            MallardDuck mallardDuck = new MallardDuck();
            WildTurkey  wildTurkey  = new WildTurkey();

            IDuck turkeyAdapter = new TurkeyAdapter(wildTurkey);

            Console.WriteLine("\nThe Turkey says...");
            wildTurkey.Gobble();
            wildTurkey.Fly();

            Console.WriteLine("\nThe Duck says");
            TestDuck(mallardDuck);

            Console.WriteLine("\nThe TurkeyAdapter says");
            TestDuck(turkeyAdapter);
        }
Example #8
0
        public static void Adapter()
        {
            MallardDuck duck = new MallardDuck();

            WildTurkey turkey = new WildTurkey();

            Duck turkeyAdapter = new TurkeyAdapter(turkey);

            Console.WriteLine("The Turkey says");
            turkey.Gobble();
            turkey.Fly();

            Console.WriteLine("The Duck says...");
            TestDuck(duck);

            Console.WriteLine("The Turkey Adapter says...");
            TestDuck(turkeyAdapter);
        }
        static void Main()
        {
            IDuck duck = new MallardDuck();

            duck.Quack();
            duck.Fly();

            ITurkey turkey = new WildTurkey();

            turkey.Gobble();
            turkey.Fly();

            IDuck adapter = new DuckAdapter(turkey);

            adapter.Quack();
            adapter.Fly();

            Console.ReadLine();
        }
Example #10
0
        static void Main(string[] args)
        {
            WildTurkey  turkey = new WildTurkey();
            MallardDuck duck   = new MallardDuck();


            Duck turkeyAdapter = new TurkeyAdapter(turkey);

            turkeyAdapter.Fly();
            turkeyAdapter.Quack();

            //Console.WriteLine("The turkey says");
            //turkey.Gobble();
            //turkey.fly();
            //Console.WriteLine("The duck says");
            //testDuck(duck);
            //Console.WriteLine("The TurkeyAdapter says");
            //testDuck(turkeyAdapter);
        }
        static void Main(string[] args)
        {
            //Se crean objetos Pato y Pavo.
            MallardDuck duck   = new MallardDuck();
            WildTurkey  turkey = new WildTurkey();
            //Se crea un Pavo disfrazado de Pato envolviendolo en un adaptador.
            IDuck turkeyAdapter = new TurkeyAdapter(turkey);

            Console.WriteLine("The Turkey says: ");
            turkey.Gobble();
            turkey.Fly();

            Console.WriteLine("\nThe Duck says: ");
            duck.Quack();
            duck.Fly();

            Console.WriteLine("\nThe Undercover Turkey says: ");
            testDuck(turkeyAdapter);
            Console.ReadKey();
        }