Пример #1
0
        static void Main(string[] args)
        {
            Duck       mallard     = new MallardDuck();
            RubberDuck rubber      = new RubberDuck();
            Duck       rubberDucky = new RubberDuck();

            mallard.performFly();
            mallard.performQuack();
            mallard.swim();
            mallard.Display();

            rubber.performFly();
            rubber.performQuack();
            rubber.swim();
            rubber.Display();
            rubber.setFlyBehaviour(new FlyWithWings());
            rubber.performFly();

            mallard.setFlyBehaviour(new FlyWithRocket());
            mallard.performFly();
            mallard.setQuackBehaviour(new StrongQuack());
            mallard.performQuack();

            rubberDucky.setFlyBehaviour(new FlyWithRocket());
            rubberDucky.performQuack();

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Duck myduck = new MallardDuck();

            myduck.display();
            myduck.performFly();
            myduck.performQuack();

            myduck = new RedHeadDuck();
            myduck.display();
            myduck.performFly();
            myduck.performQuack();

            myduck = new RubberDuck();
            myduck.display();
            myduck.performFly();
            myduck.performQuack();

            myduck = new DecoyDuck();
            myduck.display();
            myduck.performFly();
            myduck.performQuack();

            myduck.setFlyBehavior(new FlyJet());
            myduck.performFly();
        }
Пример #3
0
        static void Main(string[] args)
        {
            Duck num1 = new MallardDuck();

            num1.display();
            num1.performFly();
            num1.performQuack();
            num1.Swim();

            Duck num2 = new RedheadDuck();

            num2.display();
            num2.performFly();
            num2.performQuack();
            num2.Swim();

            Duck num3 = new DecoyDuck();

            num3.display();
            num3.performFly();
            num3.performQuack();
            num3.Swim();
            num3.setFlyBehavior(new FlyWithWings());
            num3.performFly();

            Console.Read();
        }
Пример #4
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.performQuack();
            mallard.performFly();

            Duck model = new ModelDuck();

            model.performFly();
            model.flyBehavior = new FlyRocketPowered();
            model.performFly();
        }
Пример #5
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.performQuack();
            mallard.performFly();

            //model duck dynamically changed its flying behavior
            Duck model = new ModelDuck();

            model.performFly();
            model.setFlyBehavior(new FlyRocketPowered());
            model.performFly();
        }
Пример #6
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck(new Quack(), new FlyWithWings());

            mallard.performQuack();
            mallard.performFly();

            Duck model = new ModelDuck(new Quack(), new FlyNoWay());

            model.performFly();
            model.flyBehavior = new FlyRockectPowered();
            model.performFly();
            model.performQuack();
            Console.Read();
        }
Пример #7
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.performQuack();
            mallard.performFly();

            Duck model = new ModelDuck();

            model.performFly();
            model.setFlyBehavior(new FlyRocketPowerd());
            model.performFly();

            Console.ReadLine();
        }
Пример #8
0
        static void Main()
        {
            Duck mallard = new MallardDuck();

            mallard.performFly();
            mallard.performQuack();
            mallard.display();


            Duck model = new ModelDuck();

            model.performFly();
            model.setFlyBehaviour(new FlyRocketPowered());
            model.performFly();

            Console.ReadKey();
        }
Пример #9
0
        static void Main(string[] args)
        {
            Duck Mallard = new MallardDuck();

            Mallard.performFly();
            Mallard.performQuack();

            Duck model = new ModelDuck();

            model.performFly();
            model.setFlyBehaviour(new FlyWithWings());
            model.performFly();

            //no vuela
            Duck model2 = new ModelDuck();

            model.performFly();
            model.setFlyBehaviour(new FlyNoWay());
            model.performFly();
        }