Esempio n. 1
0
        static void Main(string[] args)
        {
            List <Duck> pond = new List <Duck>();//пруд с уточками

            pond.Add(new MallardDuck());
            pond.Add(new ModelDuck());

            foreach (Duck duck in pond)
            {
                duck.display();
                duck.performQuack();
                duck.performFly();
                Console.WriteLine("");
            }
            Console.WriteLine("Load force");
            Console.WriteLine("Ready to start!");
            Console.WriteLine("");
            Duck forced = new ModelDuck();

            forced.setFlyBehavior(new ReactiveFlying());

            forced.display();
            forced.performQuack();
            forced.performFly();

            Console.ReadKey();
        }
Esempio n. 2
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();
        }