示例#1
0
        static void Main(string[] args)
        {
            MallardDuck duck = new MallardDuck();

            WildTurkey turkey        = new WildTurkey();
            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 TurkeyAdapter says...");
            turkeyAdapter.Quack();
            turkeyAdapter.Fly();
        }
        public static void Main(string[] args)
        {
            MallardDuck duck = new MallardDuck();

            WildTurkey turkey        = new WildTurkey();
            IDuck      turkeyAdapter = new TurkeyAdapter(turkey);

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

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

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

            Console.ReadKey();
        }