예제 #1
0
        public MallardDuck()
        {
            // 具体编程.

            // 把行为设定为具体的类

            // 可以在运行时 指定不同的实例化对象
            m_FlyBehavior   = new FlyWithWings();
            m_QuackBehavior = new NormalQuack();
        }
예제 #2
0
 public NormalDuck()
 {
     flyBehaviour   = new FlyWithWings();
     quackBehaviour = new NormalQuack();
 }
예제 #3
0
 public ModelDuck()
 {
     m_FlyBehavior   = new FlyNoWay();
     m_QuackBehavior = new NormalQuack();
 }