static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.FlyBehavior = new FlyWithWings(); mallard.QuackBehavior = new Quack(); mallard.PerformFly(); mallard.PerformQuack(); mallard.Swim(); }
static void Main(string[] args) { Duck mallard = new MallardDuck(); mallard.PerformQuack(); mallard.PerformFly(); Duck model = new ModelDuck(); model.PerformFly(); model.SetFlyBehaviour(new FlyWithRocket()); model.PerformFly(); }
public void Run() { Duck mallardDuck = new MallardDuck(); mallardDuck.Quack(); mallardDuck.Fly(); Duck modelDuck = new ModelDuck(); modelDuck.Quack(); modelDuck.Fly(); Console.WriteLine("Changing model duck's flying behavior..."); modelDuck.FlyBehavior = new FlyRocketPowered(); modelDuck.Fly(); }
public static void Main(string[] args) { MallardDuck mallard = new MallardDuck(); RubberDuck rubberDuckie = new RubberDuck(); DecoyDuck decoy = new DecoyDuck(); ModelDuck model = new ModelDuck(); mallard.PerformQuack(); rubberDuckie.PerformQuack(); decoy.PerformQuack(); model.PerformFly(); model.FlyBehavior = new FlyRocketPowered(); model.PerformFly(); }