public RedHeadDuck() { quackBehavior = new Quack(); flyBehavior = new FlyWithWings(); }
public MallardDuck() { _quackBehavior = new Quack(); _flyBehavior = new FlyWithWings(); }
public ModelDuck() { _flyBehavior = new FlyNoWay(); _quackBehavior = new Quack(); }
public MallardDuck() { FlyBehaviour = new FlyWithWings(); QuackBehaviour = new Quack(); }
/// <summary> /// 写一个构造函数,可以保证创建对象时,将实例复制给父类的quackBehavior /// </summary> public MallardDuck() { quackBehavior = new Quack(); //绿头鸭使用Quack类处理呱呱叫,所以当performQuack()被调用时,叫的职责被委托给Quack对象,而我们得到了真正的呱呱叫。 flyBehavior = new FlyWithWings(); //使用FlyWithWings作为其FlyBehavior类型。 }
public ModelDuck() { FlyBehavior = new FlyNoWay(); QuackBehavior = new Quack(); }
public ModeDuck() { flyBehavior = new FlyNoWay(); quackBehavior = new Quack(); }
public GreenHeadDuck() { flyBehavior = new FlyWithWings(); quackBehavior = new Quack(); }
public MallardDuck() { quackBehavior = new Quack(); flyBehavior = new Fly(); }
public override void AssignQuackBehavior() { quackBehavior = new Quack(); }
public RedheadDuck() { flyBehavior = new FlyWithWings(); quackBehavior = new Quack(); }