public void TestWildTurkey()
        {
            Turkey wildTurkey = new WildTurkey();

            Assert.AreEqual("Gooble, gooble", wildTurkey.Gobble());
            Assert.AreEqual("I'm flying a short distance", wildTurkey.Fly());
        }
        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();
        }
Example #3
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();
        }
Example #4
0
        public 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...");
            TestDuck(duck);

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

            ITurkey duckAdapter = new DuckAdapter(duck);

            Console.WriteLine("");
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("The DuckAdapter says...");
                duckAdapter.Gobble();
                duckAdapter.Fly();
            }
        }
Example #5
0
 public void Quack()
 {
     for (int i = 0; i < 5; i++)
     {
         turkey.Gobble();
     }
 }
        public void TurkeyShouldGobble()
        {
            var expected = "gobble gobble";

            WildTurkey wildTurkey = new WildTurkey();

            var result = wildTurkey.Gobble();

            result.Should().Be(expected);
        }
Example #7
0
        static void Main(string[] args)
        {
            WildTurkey turkey        = new WildTurkey();
            IDuck      turkeyAdapter = new TurkeyAdapter(turkey);

            turkey.Gobble();
            turkey.Fly();
            turkeyAdapter.Quack();
            turkeyAdapter.Fly();
        }
        public void TestAdapter()
        {
            var turkey  = new WildTurkey();
            var adapter = new TurkeyAdapter(turkey);

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

            adapter.Fly();
            adapter.Quack();
        }
Example #9
0
        static void Main(string[] args)
        {
            MallardDuck mallard       = new MallardDuck();
            WildTurkey  wild          = new WildTurkey();
            IDuck       turkeyAdapter = new TurkeyAdapter(wild);

            Console.WriteLine("The Turkey says...");
            wild.Gobble();
            wild.Fly();
            Console.WriteLine("\nThe Duck says...");
            TestDuck(mallard);

            Console.WriteLine("The TurkeyAdapter says...");
            TestDuck(turkeyAdapter);
        }
Example #10
0
        public static void Start()
        {
            var duck           = new MallardDuck();
            var turkey         = new WildTurkey();
            var turkeyLikeDuck = new TurkeyAdapter(turkey);

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

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

            turkeyLikeDuck.Quack();
            turkeyLikeDuck.Fly();
        }
        static void Main(string[] args)
        {
            var duck          = new MallardDuck();
            var turkey        = new WildTurkey();
            var turkeyAdapter = new TurkeyAdaptor(turkey);

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

            Console.WriteLine("\nThe duck says...");
            testDuck(duck);

            Console.WriteLine("\nThe turkey adaptor says...");
            testDuck(turkeyAdapter);
        }
        static void Main(string[] args)
        {
            MallardDuck duck   = new MallardDuck();
            WildTurkey  turkey = new WildTurkey();

            IDuck turkeyAdapter = new TurkeyAdapter(turkey);

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

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

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

            IDuck fakeTurkey = new TurkeyAdapter(turkey);

            Console.WriteLine("\n----------Turkey Said-----------\n");
            turkey.Gobble();
            turkey.Fly();

            Console.WriteLine("\n-----------Duck Said---------\n");
            TestDuck(duck);
            Console.WriteLine("\n----------FakeTurkey Said----------\n");
            TestDuck(fakeTurkey);
        }
Example #14
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...");
            TestDuck(duck);

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

            Console.ReadLine();
        }
        public void TurkeyAdapterTest()
        {
            MallardDuck duck = new MallardDuck();

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

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

            Console.WriteLine($"{Environment.NewLine}The Duck says...");
            TestDuck(duck);

            Console.WriteLine($"{Environment.NewLine}The TurkeyAdapter says...");
            TestDuck(turkeyAdapter);
        }
Example #16
0
        static void Main(string[] args)
        {
            var duck = new MallardDuck();

            var turkey = new WildTurkey();
            // Теперь индюшка выглядит как утка
            IDuck 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 #17
0
        static void DuckTestDrive()
        {
            IDuck duck          = new MallardDuck();
            var   turkey        = new WildTurkey();
            IDuck turkeyAdapter = new TurkeyAdapter(turkey);

            System.Console.WriteLine("Turkey says.........");
            turkey.Gobble();
            turkey.Fly();
            Console.WriteLine("-----------------------------------------------------------");
            System.Console.WriteLine("Duck says.........");
            TestDuck(duck);
            Console.WriteLine("-----------------------------------------------------------");
            System.Console.WriteLine("TurkeyAdapter says.........");
            TestDuck(turkeyAdapter);

            Console.ReadKey();
        }
Example #18
0
        public static void UseAdapterPattern(IView view)
        {
            SomeDuck duckling = new SomeDuck(view);

            WildTurkey turkey = new WildTurkey(view);

            IDuck turkeyAdapter = new TurkeyAdapter(turkey);

            view.DisplayMessage("The turkey says...");
            turkey.Gobble();
            turkey.Fly();

            view.DisplayMessage("The duck says...");
            TestDuck(duckling);

            view.DisplayMessage("The turkeyAdapter says...");
            TestDuck(turkeyAdapter);
        }
        public static void Start()
        {
            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...");

            testDuck(duck);

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

            testDuck(turkeyAdapter);
        }
Example #20
0
        private static void TestAdapterPattern()
        {
            MallardDuck duck = new MallardDuck();

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

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

            Console.WriteLine();

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

            Console.WriteLine("The TurkeyAdapter says ...");
            Console.WriteLine(TestDuck(turkeyAdapter));
        }
Example #21
0
        private static void Main(string[] args)
        {
            var duck = new MallardDuck();

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

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

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

            Console.WriteLine("The turkeyAdapter says...");
            TestDuck(turkeyAdapter);

            Console.ReadLine();
        }
Example #22
0
        static void Main(string[] args)
        {
            MallardDuck md = new MallardDuck();
            WildTurkey  wd = new WildTurkey();
            IDuck       ta = new TurkeyAdapter(wd);

            System.Console.WriteLine("\r\nMallard Duck:");
            md.Quack();
            md.Fly();

            System.Console.WriteLine("\r\nWild Turkey:");
            wd.Gobble();
            wd.Fly();

            System.Console.WriteLine("\r\nTurkey Adapter:");
            ta.Quack();
            ta.Fly();

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            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...");
            testDuck(duck);

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

            Bitcoin bitcoin = new Bitcoin();

            USDollars usd = new USDollars();

            IBit bitAdapter = new BitcoinToUSDollarsAdapter(bitcoin);

            IUSD usdAdapter = new USDollarToBitcoinAdapter(usd);

            Console.WriteLine($"\nYou have ${usd.GetBalance()} in your account.");

            Console.WriteLine($"\nYou have {bitcoin.GetBalance()} bitcoins in your account.");

            bitAdapter.Deposit(5000);

            usdAdapter.Deposit(1.5);

            Console.WriteLine($"\nYou have ${usd.GetBalance()} in your account.");

            Console.WriteLine($"\nYou have {bitcoin.GetBalance()} bitcoins in your account.");
        }
 public string Quack()
 {
     return(turkey.Gobble());
 }