static void Main(string[] args) { List <Duck> listDucks = new List <Duck>(); IFlybehaviour fbNW = new FlyNoWay(); IFlybehaviour fww = new FlyWithWings(); MallardDuck md = new MallardDuck(); md.SetFly(fww); RedheadDuck rh = new RedheadDuck(); rh.SetFly(fww); RubberDuck rd = new RubberDuck(); rd.SetFly(fbNW); DecoyDuck dd = new DecoyDuck(); dd.SetFly(fbNW); listDucks.Add(md); listDucks.Add(rh); listDucks.Add(rd); listDucks.Add(dd); foreach (var duck in listDucks) { //duck.Quack(); duck.Swim(); duck.Fly(); } }
void simulate() { IQuackable mallardDuck = new MallardDuck(); IQuackable redheadDuck = new RedheadDuck(); IQuackable duckCall = new DuckCall(); IQuackable rubberDuck = new RubberDuck(); Console.WriteLine("Duck Simulator"); simulate(mallardDuck); simulate(redheadDuck); simulate(duckCall); simulate(rubberDuck); }