示例#1
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();
            mallard.Display();
            mallard.PerformQuack();
            mallard.PerformFly();

            Duck fauxDuck = new ModelDuck();
            fauxDuck.Display();
            fauxDuck.PerformQuack();
            fauxDuck.PerformFly();

            Duck disabledMallard = new MallardDuck()
                {
                    FlyBehavior = new CannotFlyBehavior(),
                    QuackBehavior = new MuteBehavior()
                };
            disabledMallard.Display();
            disabledMallard.PerformFly();
            disabledMallard.PerformQuack();

            fauxDuck.FlyBehavior = new JetPackBehavior();
            fauxDuck.Display();
            fauxDuck.PerformFly();

            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.Display();
            mallard.PerformQuack();
            mallard.PerformFly();

            Duck fauxDuck = new ModelDuck();

            fauxDuck.Display();
            fauxDuck.PerformQuack();
            fauxDuck.PerformFly();

            Duck disabledMallard = new MallardDuck()
            {
                FlyBehavior   = new CannotFlyBehavior(),
                QuackBehavior = new MuteBehavior()
            };

            disabledMallard.Display();
            disabledMallard.PerformFly();
            disabledMallard.PerformQuack();

            fauxDuck.FlyBehavior = new JetPackBehavior();
            fauxDuck.Display();
            fauxDuck.PerformFly();

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

            mallard.Display();
            mallard.PerformQuack();
            mallard.PerformFly();
            Console.WriteLine();

            Duck model = new ModelDuck();

            model.Display();
            model.PerformQuack();
            model.PerformFly();
            model.SetFlyBehaviour(new FlyRocketPowered());
            model.PerformFly();
            Console.WriteLine();

            Duck decoy = new DecoyDuck();

            decoy.Display();
            decoy.PerformQuack();
            decoy.PerformFly();
            decoy.SetQuackBehaviour(new Squeak());
            Console.WriteLine();

            Duck rubber = new RubberDuck();

            rubber.Display();
            rubber.PerformQuack();
            rubber.PerformFly();
            rubber.Swim();
            Console.WriteLine();
        }
示例#4
0
        private static void MiniDuckSimulator()
        {
            var mallard = new MallardDuck();

            mallard.Display();
            mallard.PerformFly();
            mallard.PerformQuack();

            var model = new ModelDuck();

            model.Display();
            model.PerformFly();
            model.PerformQuack();
            Console.WriteLine("---------\r\n>>> powered by rocket.");
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
示例#5
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.Display();
            mallard.PerformFly();
            mallard.PerformQuack();

            Console.WriteLine();

            Duck model = new ModelDuck();

            model.Display();
            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
示例#6
0
        static void Main(string[] args)
        {
            Duck real = new RealDuck();

            real.Display();
            real.PerformFly();
            real.PerformQuack();

            real.SetFlyBehavior(new FlyNoWay());
            real.PerformFly();

            Duck model = new ModelDuck();

            model.Display();
            model.PerformFly();
            model.PerformQuack();

            model.SetQuackBehavior(new DuckQuack());
            model.PerformQuack();

            Console.Read();
        }
示例#7
0
        static void Main(string[] args)
        {
            Duck Mallard = new MallardDuck();

            Mallard.Display();
            Mallard.PerformQuack();
            Mallard.PerformFly();

            Duck Model = new ModelDuck();

            Console.WriteLine();
            Model.Display();
            Model.PerformQuack();
            Model.PerformFly();
            Model.SetFlyBehavior(new FlyRocketPowered());
            Model.PerformFly();

            Duck Redhead = new RedheadDuck();

            Console.WriteLine();
            Redhead.Display();
            Redhead.PerformQuack();
            Redhead.PerformFly();

            Duck Rubber = new RubberDuck();

            Console.WriteLine();
            Rubber.Display();
            Rubber.PerformQuack();
            Rubber.PerformFly();

            Duck Decoy = new DecoyDuck();

            Console.WriteLine();
            Decoy.Display();
            Decoy.PerformQuack();
            Decoy.PerformFly();
        }