예제 #1
0
        static void Main(string[] args)
        {
            //作业:橡皮rubber鸭子、木wood鸭子、真实的鸭子realduck。
            //三个鸭子都会游泳,而橡皮鸭子和真实的鸭子都会叫,
            //只是叫声不一样,橡皮鸭子“唧唧”叫,真实地鸭子“嘎嘎”叫,木鸭子不会叫.
            //IBark bark = new RealDuck();//new XPDuck();
            //bark.Bark();
            XPDuck   xp   = new XPDuck();
            MuDuck   md   = new MuDuck();
            RealDuck rd   = new RealDuck();
            IBark    bark = rd;
            Duck     duck = rd;

            duck.Swim();
            bark.Bark();


            Console.ReadKey();
        }
예제 #2
0
 public Behavior(IBark bark, IWalk walk)
 {
     this.bark = bark;
     this.walk = walk;
 }