static void Main(string[] args) { List <Duck> pond = new List <Duck>();//пруд с уточками pond.Add(new MallardDuck()); pond.Add(new ModelDuck()); foreach (Duck duck in pond) { duck.display(); duck.performQuack(); duck.performFly(); Console.WriteLine(""); } Console.WriteLine("Load force"); Console.WriteLine("Ready to start!"); Console.WriteLine(""); Duck forced = new ModelDuck(); forced.setFlyBehavior(new ReactiveFlying()); forced.display(); forced.performQuack(); forced.performFly(); Console.ReadKey(); }
static void Main(string[] args) { //Duck.Duck mallard = new MallardDuck(); //mallard.PerformQuack(); //mallard.PerformFly(); Duck.Duck model = new ModelDuck(); model.PerformFly(); model.setFlyBehavior(new FlyRocketPowered()); model.PerformFly(); }
static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.performQuack(); mallard.performFly(); //model duck dynamically changed its flying behavior Duck model = new ModelDuck(); model.performFly(); model.setFlyBehavior(new FlyRocketPowered()); model.performFly(); }
static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.performQuack(); mallard.performFly(); Duck model = new ModelDuck(); model.performFly(); model.setFlyBehavior(new FlyRocketPowerd()); model.performFly(); Console.ReadLine(); }
static void Main(string[] args) { Duck greenDuck = new GreenDuck(); greenDuck.PeformaneFly(); greenDuck.PeformaneQuack(); Duck modelDuck = new ModelDuck(); modelDuck.PeformaneFly(); modelDuck.PeformaneQuack(); modelDuck.setFlyBehavior(new FlyWithWing()); modelDuck.setQuackBehavior(new MuteSqueak()); modelDuck.PeformaneFly(); modelDuck.PeformaneQuack(); Console.ReadLine(); }