Пример #1
0
        public static void main(String[] args)
        {
            var oDuck = new MallardDuck();

            var   oTurkey        = new WildTurkey();
            IDuck oTurkeyAdapter = new TurkeyAdapter(oTurkey);

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

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

            Console.WriteLine("\nThe TurkeyAdapter says");
            TestDuck(oTurkeyAdapter);
        }
Пример #2
0
        public void Run()
        {
            MallardDuck mallardDuck = new MallardDuck();
            WildTurkey  wildTurkey  = new WildTurkey();

            IDuck turkeyDuck = new TurkeyAdapter(wildTurkey);

            Console.WriteLine("Testing turkey...");
            wildTurkey.Gobble();
            wildTurkey.Fly();

            Console.WriteLine();
            Console.WriteLine("Testing duck...");
            testDuck(mallardDuck);

            Console.WriteLine();
            Console.WriteLine("Testing turkey duck...");
            testDuck(turkeyDuck);
        }