/// <summary>
 /// A MallardDuck uses the Quack class to handle its Quack,
 /// so when PerformQuack is called, the responsibility for
 /// the Quack is delegated to the Quack object and we get a real Quack.
 /// And it uses FlyWithWings as its IFlyBehavior.
 /// </summary>
 public MallardDuck()
 {
     // These two instance variables are inherited from the Duck superclass.
     quackBehavior = new Quacks();
     flyBehavior   = new FlyWithWings();
 }
Esempio n. 2
0
 /// <summary>
 /// Model duck subclass
 /// </summary>
 public ModelDuck()
 {
     // The model duck begins like grounded without a way to fly.
     flyBehavior   = new FlyNoWay();
     quackBehavior = new Quacks();
 }