예제 #1
0
        static void Main(string[] args)
        {
            IDuck   duck          = new Duck();
            ITurkey turkey        = new Turkey();
            IDuck   turkeyAdapter = new TurkeyAdapter(turkey);

            Console.WriteLine();
            duck.Fly();
            duck.Quack();

            Console.WriteLine();
            turkey.Fly();
            turkey.Gobble();

            Console.WriteLine();
            turkeyAdapter.Fly();
            turkeyAdapter.Quack();

            Console.WriteLine();
            Action(duck);

            Console.WriteLine();
            Action(turkeyAdapter);

            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var turkey        = new WildTurkey();
            var turkeyAdapter = new TurkeyAdapter(turkey);

            turkeyAdapter.Fly();
            turkeyAdapter.Quack();
        }
예제 #3
0
        static void Main(string[] args)
        {
            MallardDuck duck   = new MallardDuck();
            WildTurkey  turkey = new WildTurkey();

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

            Console.WriteLine("The duck says");
            duck.Quack();
            duck.Fly();

            TurkeyAdapter adapter = new TurkeyAdapter(turkey);

            adapter.Quack();
            adapter.Fly();
        }
예제 #4
0
        static void Main(string[] args)
        {
            /*both sides*/
            ITurkey turkey = new TurkeyDuckAdapter();

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

            /*Turkey to duck*/

            Turkey turkeyy = new Turkey();

            IDuck turkeyAdapter = new TurkeyAdapter(turkeyy);

            Console.WriteLine("----------------------------------");
            turkeyAdapter.Fly();
            turkeyAdapter.Quack();
            Console.ReadKey();
        }