Пример #1
0
        private void RunAdapterExample()
        {
            Duck    rubberDuck = new RubberDuck();
            ITurkey wildTurkey = new WildTurkey();

            TurkeyToDuckAdapter turkey = new TurkeyToDuckAdapter(wildTurkey);

            turkey.PerformFly();
            turkey.PerformQuack();
        }
        static void Main(string[] args)
        {
            MallardDuckInfo duck   = new MallardDuckInfo();
            WildTurkeyInfo  turkey = new WildTurkeyInfo();

            IDuck turkeyAdapter = new TurkeyToDuckAdapter(turkey);

            Console.WriteLine("--== Turkey To Duck Adapter ==--");
            turkeyAdapter.Quack();
            turkeyAdapter.Fly();
            Console.WriteLine();

            ITurkey duckAdapter = new DuckToTurkeyAdapter(duck);

            Console.WriteLine("--== Duck To Turkey Adapter ==--");
            duckAdapter.Gobble();
            duckAdapter.Fly();

            Console.ReadLine();
        }