static void Main(string[] args)
 {
     var turkey = new WildTurkey();
     var duck = new DuckAdapter(turkey);
     duck.Sing();
     duck.Fly();
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            MallardDuck duck   = new MallardDuck();
            WildTurkey  turkey = new WildTurkey();

            IDuck turkeyAdapter = new TurkeyAdapter(turkey);

            Console.WriteLine("\t---Turkey!!!---");
            turkey.Fly();
            turkey.Gobble();
            // Ошибка так как Turkey реализует интерфейс ITurkey
            //TestDuck(turkey);
            TestDuck(turkeyAdapter);

            Console.WriteLine("\n\t---Duck!!!---");
            duck.Fly();
            duck.Quack();

            Console.WriteLine("\t---Turkey!!!---");
            TestDuck(turkeyAdapter);

            Console.WriteLine("\n\t---Duck!!!---");
            TestDuck(duck);

            Console.WriteLine("\n\t---Duck!!!---");
            ITurkey duckAdapter = new DuckAdapter(duck);

            duckAdapter.Fly();
            duckAdapter.Gobble();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            IDuck duck = new MallardDuck();

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

            ITurkey turkey = new WildTurkey();

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

            IDuck adapterDuck = new TurkeyAdapter(turkey);

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

            ITurkey adapterTurkey = new DuckAdapter(duck);

            adapterTurkey.Fly();
            adapterTurkey.Gobble();

            Console.ReadKey();
        }
Exemplo n.º 4
0
        static void Main()
        {
            var simpleDuck   = new SimpleDuck();
            var simpleTurkey = new SimpleTurkey();

            var duckAdapter   = new DuckAdapter(simpleDuck);
            var turkeyAdapter = new TurkeyAdapter(simpleTurkey);

            var duckFacade = new DuckAndTurkeyFacade(simpleDuck, simpleTurkey);

            Console.WriteLine("\nTurkey:");
            TestTurkey(simpleTurkey);

            Console.WriteLine("\nDuck:");
            TestDuck(simpleDuck);

            Console.WriteLine("\nTurkey w/ adapter:");
            TestDuck(turkeyAdapter);

            Console.WriteLine("\nDuck w/ adapter:");
            TestTurkey(duckAdapter);

            Console.WriteLine("\n");

            duckFacade.IsWorking();

            Console.ReadKey();
        }
        public void TestDuckAdapter()
        {
            Duck   mallard     = new MallardDuck();
            Turkey duckAdapter = new DuckAdapter(mallard);

            Assert.AreEqual("Quack", duckAdapter.Gobble());
            Assert.AreEqual("I'm flying", duckAdapter.Fly());
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var turkey = new WildTurkey();
            var duck   = new DuckAdapter(turkey);

            duck.Sing();
            duck.Fly();
        }
        public void DuckAdapterTest()
        {
            MallardDuck duck        = new MallardDuck();
            ITurkey     duckAdapter = new DuckAdapter(duck);

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("The DuckAdapter says...");
                duckAdapter.Gobble();
                duckAdapter.Fly();
            }
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            IDog  dog  = new WildDog();
            IDuck duck = new WildDuck();

            dog.Bark();
            duck.Quack();
            dog.Jump();
            duck.Fly();
            DuckAdapter adapterDuck = new DuckAdapter(dog);

            adapterDuck.Quack();
            adapterDuck.Fly();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            MallardDuck mallardDuck = new MallardDuck();
            WildTurkey  turkey      = new WildTurkey();

            TestDuck(mallardDuck);
            TestTurkey(turkey);
            IDuck turkeyAdapter = new TurkeyAdapter(turkey);

            TestDuck(turkeyAdapter);
            ITurkey duckAdapter = new DuckAdapter(mallardDuck);

            TestTurkey(duckAdapter);
        }
Exemplo n.º 10
0
        public static void Run()
        {
            MallardDuck duck        = new MallardDuck();
            ITurkey     duckAdapter = new DuckAdapter(duck);

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

            Console.WriteLine("The Turkey says ...");
            testTurkey(turkey);

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

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

            Console.WriteLine("\nThe DuckAdapter says ...");
            testTurkey(duckAdapter);
        }
Exemplo n.º 11
0
        static void Adapter()
        {
            Console.WriteLine("Duck:");
            Adapter.Classes.Duck duck = new Adapter.Classes.Duck();
            duck.Quack();
            duck.Fly();
            Console.WriteLine();

            Console.WriteLine("Turkey:");
            Turkey turkey = new Turkey();

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

            Console.WriteLine("DuckAdapter:");
            DuckAdapter duckAdapter = new DuckAdapter(turkey);

            duckAdapter.Quack();
            duckAdapter.Fly();
        }
Exemplo n.º 12
0
        public void DuckAdapterReturnProperlyQuack()
        {
            var d = new DuckAdapter(new AnAnimal("Ghepard"));

            Assert.IsTrue(d.Display() == "Ghepard");
        }
Exemplo n.º 13
0
        public void DuckAdapterIsDuck()
        {
            var d = new DuckAdapter(new AnAnimal("Ghepard"));

            Assert.IsTrue(d is global::Ducks.Ducks);
        }