public RedheadDuck()
 {
     FlyBehavior   = new FlyWithWings();
     QuackBehavior = new DuckQuack();
 }
 public MallardDuck() {
     _quackBehavior = new Quack();
     _flyBehavior = new FlyWithWings();
 }
Esempio n. 3
0
 public MallardDuck()
 {
     flyBehaviour   = new FlyWithWings();
     quackBehaviour = new QuackDuck();
 }
Esempio n. 4
0
 public MallardDuck()
 {
     QuackBehavior = new Quack();
     FlyBehavior   = new FlyWithWings();
 }
Esempio n. 5
0
 /// <summary>
 /// 写一个构造函数,可以保证创建对象时,将实例复制给父类的quackBehavior
 /// </summary>
 public MallardDuck()
 {
     quackBehavior = new Quack();        //绿头鸭使用Quack类处理呱呱叫,所以当performQuack()被调用时,叫的职责被委托给Quack对象,而我们得到了真正的呱呱叫。
     flyBehavior   = new FlyWithWings(); //使用FlyWithWings作为其FlyBehavior类型。
 }
Esempio n. 6
0
 public DuckTyp1()
 {
     flyBehavior = new FlyWithWings();
 }
Esempio n. 7
0
 public GreenHeadDuck()
 {
     flyBehavior   = new FlyWithWings();
     quackBehavior = new Quack();
 }
Esempio n. 8
0
 public Fighter()
 {
     _fly = new FlyWithWings();
     _shoot = new ShootWithGun();
 }
Esempio n. 9
0
 public RedheadDuck()
 {
     flyBehavior   = new FlyWithWings();
     quackBehavior = new Quack();
 }