static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.Quack(); mallard.Fly(); Duck model = new ModelDuck(); model.Fly(); model.Fly = FlyRocketPowered; model.Fly(); }
static void Main(string[] args) { DuckBase mallard = new MallardDuck(); mallard.Quack(); mallard.Fly(); DuckBase model = new ModelDuck(); model.Fly(); model.SetFlyBehavior(new FlyRocketPowered()); model.Fly(); Console.ReadLine(); }
static void Main(string[] args) { Duck modelDuck = new ModelDuck(); FlyBehavior flyBehavior = new FlyNoWay(); modelDuck.FlyBehavior = flyBehavior; modelDuck.Fly(); Console.ReadKey(); }
static void Main(string[] args) { MallardDuck mallard = new MallardDuck(); mallard.Quack(); mallard.SetQuackBehavior(new Squeak()); Console.WriteLine("-- Change Quack Behavior --"); mallard.Quack(); Console.WriteLine("---------------------"); var model = new ModelDuck("Model Duck"); model.Fly(); model.SetFlyBehavior(new FlyRocketPowered()); Console.WriteLine("-- Change Quack Behavior --"); model.Fly(); }
static void Main(string[] args) { Console.WriteLine("Simulating Mullard Duck... \r\n"); var mallard = new MullardDuck(); mallard.Quack(); mallard.Fly(); Console.WriteLine("\r\nSimulating Model Duck... \r\n"); var model = new ModelDuck(); model.Quack(); model.Fly(); Console.Read(); }