Exemplo n.º 1
0
        static void Main(string[] args)
        {
            IDuck   duck          = new Duck();
            ITurkey turkey        = new Turkey();
            IDuck   turkeyAdapter = new TurkeyAdapter(turkey);

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

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

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

            Console.WriteLine();
            Action(duck);

            Console.WriteLine();
            Action(turkeyAdapter);

            Console.ReadKey();
        }
Exemplo n.º 2
0
 public void Fly()
 {
     for (int i = 0; i != 5; ++i)
     {
         turkey.Fly();
     }
 }
Exemplo n.º 3
0
        public string fly()
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 5; i++)
            {
                sb.Append(turkey.Fly());
                sb.Append("\n");
            }

            return(sb.ToString());
        }