Beispiel #1
0
 // constructor
 public ModelDuck()
 {
     flyBehavior   = new FlyNoWay(); // interface = class
     quackBehavior = new Quack();    // interface = class
 }
Beispiel #2
0
 // constructor
 public MallardDuck()
 {
     quackBehavior = new Quack();        // quackBehavior is a vairable from the base class. Quack is a concrete class (behavior) that implements the IQuackBehavior interface.
     flyBehavior   = new FlyWithWings(); // flyBehavior is a variable from the base class. FlyWithWings is a concrete class (behavior) that implements the IFlyBehavior interface.
 }