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(); } }
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(); }
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(); }