コード例 #1
0
        private static void TurkeyTestDrive()
        {
            IDuck   duck        = new MallardDuck();
            ITurkey duckAdapter = new DuckAdapter(duck);

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("The DuckAdapter says...");
                duckAdapter.Gobble();
                duckAdapter.Fly();
            }
        }
コード例 #2
0
        static void Main()
        {
            IDuck duck = new MallardDuck();

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

            ITurkey turkey = new WildTurkey();

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

            IDuck adapter = new DuckAdapter(turkey);

            adapter.Quack();
            adapter.Fly();

            Console.ReadLine();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: pgproject/DesignPattern
        static void Main(string[] args)
        {
            WildDuck wildDuck = new WildDuck();

            WildTurkey wildTurkey    = new WildTurkey();
            IDuck      turkeyAdapter = new TurkeyAdapter(wildTurkey);
            ITurkey    duckAdapter   = new DuckAdapter(wildDuck);

            Console.WriteLine("Indyk mówi:");
            wildTurkey.Bubble();
            wildTurkey.Fly();

            Console.WriteLine("Kaczka mówi:");
            TestDuck(wildDuck);

            Console.WriteLine("Adapter indyka mówi");
            TestDuck(turkeyAdapter);

            Console.WriteLine("Adapter kaczki mówi:");
            TestTurkey(duckAdapter);

            Console.ReadKey();
        }