private void CreateMallardDuckWithRocketAndSqueak() { Duck mallardDuck = new MallardDuck(); mallardDuck.SetFlyBehavior(new FlyRocketPowered()); mallardDuck.SetQuackBehavior(new Squeak()); mallardDuck.Display(); mallardDuck.PerformFly(); mallardDuck.PerformQuack(); }
static void Main(string[] args) { Duck myDuck = new MallardDuck(); myDuck.Display(); myDuck.PerformFly(); myDuck.PerformQuack(); myDuck.SetFlyBehavior(new FlyWithWingsTypeTwo()); myDuck.SetQuackBehavior(new NoQuack()); myDuck.PerformFly(); myDuck.PerformQuack(); myDuck = new RubberDuck(); myDuck.Display(); myDuck.PerformFly(); myDuck.PerformQuack(); myDuck.SetFlyBehavior(new FlyWithJet()); myDuck.SetQuackBehavior(new QuackLikeMallardDuck()); myDuck.PerformFly(); myDuck.PerformQuack(); }