Пример #1
0
        private void CreateMallardDuckWithRocketAndSqueak()
        {
            Duck mallardDuck = new MallardDuck();

            mallardDuck.SetFlyBehavior(new FlyRocketPowered());
            mallardDuck.SetQuackBehavior(new Squeak());
            mallardDuck.Display();
            mallardDuck.PerformFly();
            mallardDuck.PerformQuack();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Duck myDuck = new MallardDuck();

            myDuck.Display();
            myDuck.PerformFly();
            myDuck.PerformQuack();
            myDuck.SetFlyBehavior(new FlyWithWingsTypeTwo());
            myDuck.SetQuackBehavior(new NoQuack());
            myDuck.PerformFly();
            myDuck.PerformQuack();

            myDuck = new RubberDuck();
            myDuck.Display();
            myDuck.PerformFly();
            myDuck.PerformQuack();
            myDuck.SetFlyBehavior(new FlyWithJet());
            myDuck.SetQuackBehavior(new QuackLikeMallardDuck());
            myDuck.PerformFly();
            myDuck.PerformQuack();
        }