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(); }
static void Main(string[] args) { var turkey = new WildTurkey(); var turkeyAdapter = new TurkeyAdapter(turkey); turkeyAdapter.Fly(); turkeyAdapter.Quack(); }
static void Main(string[] args) { MallardDuck duck = new MallardDuck(); WildTurkey turkey = new WildTurkey(); Console.WriteLine("The turkey says :"); turkey.Gobble(); turkey.Fly(); Console.WriteLine("The duck says"); duck.Quack(); duck.Fly(); TurkeyAdapter adapter = new TurkeyAdapter(turkey); adapter.Quack(); adapter.Fly(); }
static void Main(string[] args) { /*both sides*/ ITurkey turkey = new TurkeyDuckAdapter(); turkey.Fly(); turkey.Gobble(); /*Turkey to duck*/ Turkey turkeyy = new Turkey(); IDuck turkeyAdapter = new TurkeyAdapter(turkeyy); Console.WriteLine("----------------------------------"); turkeyAdapter.Fly(); turkeyAdapter.Quack(); Console.ReadKey(); }