public void TestModelDuck()

        {
            HeadFirstDesignPatterns.Strategy.Duck.Duck ModelDuck = new ModelDuck();

            Assert.AreEqual("Quack", ModelDuck.PerformQuack());

            Assert.AreEqual("I can't fly.", ModelDuck.PerformFly());



            ModelDuck.FlyBehavoir = new FlyRocketPowered();

            Assert.AreEqual("I'm flying with a rocket!", ModelDuck.FlyBehavoir.Fly());

            Assert.AreEqual("I'm flying with a rocket!", ModelDuck.PerformFly());



            ModelDuck.QuackBehavior = new MuteQuack();

            Assert.AreEqual("<<silence>>", ModelDuck.QuackBehavior.Quacking());

            Assert.AreEqual("<<silence>>", ModelDuck.PerformQuack());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Game");

            Character character = new King();

            character.SetWeapon(new Knife());
            character.Fight();
            character.SetWeapon(new BowAndArrow());
            character.Fight();

            Console.WriteLine("\nDuck");

            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();

            Console.ReadKey();
        }
        public void ModelDuckTest()
        {
            Duck model = new ModelDuck();

            Assert.Equal("I can't fly!", model.PerformFly());
            model.SetFlyBehavior(new FlyRocketPowered());
            Assert.Equal("Flying with powered rocket!", model.PerformFly());
        }
Ejemplo n.º 4
0
        public void ModelDuckBySetMethodTest()
        {
            var duck = new ModelDuck();

            duck.PerformFly();
            duck.SetFlyBehavior(new FlyRocketPowered());
            duck.PerformFly();
        }
        public void model_duck_cannot_fly_then_add_rocket()
        {
            Duck model = new ModelDuck();

            Assert.AreEqual("I can't fly.", model.PerformFly());

            model.SetFlyBehaviour(new FlyRocketPowered());
            Assert.AreEqual("I'm flying with a rocket!", model.PerformFly());
        }
Ejemplo n.º 6
0
        private static void RunStrategyPattern()
        {
            Duck model = new ModelDuck();

            model.PerformFly();
            model.PerformQuack();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
        public void ModelDuck_Should_Change_FlyBehavior()
        {
            var modelDuck = new ModelDuck();

            Assert.Equal(String.Empty, modelDuck.PerformFly());

            modelDuck.FlyBehavior = new FlyRocketPowered();

            Assert.Equal("rocket fly", modelDuck.PerformFly());
        }
Ejemplo n.º 8
0
        public void DucksCanChangeFlyBehavior()
        {
            ModelDuck md = new ModelDuck();

            md.PerformFly();
            md.PerformLand();

            md.FlyBehavior = new FlyWithRockets();
            md.PerformFly();
            md.PerformLand();
        }
        public void TestMethod1()
        {
            Duck mallard = new MallardDuck();
            mallard.PerformQuack();
            mallard.PerformFly();

            Duck model = new ModelDuck();
            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
Ejemplo n.º 10
0
        public static void Start()
        {
            var mallard = new MallardDuck();

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

            var model = new ModelDuck();

            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new Implementations.FlyRocketPower());
            model.PerformFly();
        }
    static void Main(string[] args)
    {
        Duck mallard = new MallardDuck();

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

        Duck model = new ModelDuck();

        model.PerformFly();
        model.SetFlyBehaviour(new FlyRocketPowered());
        model.PerformFly();
    }
Ejemplo n.º 13
0
        public static void Run()
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
Ejemplo n.º 14
0
        public void Test2()
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();
        }
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();
            mallard.Display();
            Console.WriteLine();
            Duck model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            var mallard = new MallardDuck();
            mallard.Display();
            mallard.PerformFly();
            mallard.PerformQuack();

            var modelDuck = new ModelDuck();
            modelDuck.PerformFly();
            modelDuck.SetFlyBehavior(new FlyRocketPowered());
            modelDuck.PerformFly();

            Console.ReadKey(true);
        }
        static void Main(string[] args)
        {
            Duck duck = new MallardDuck();

            duck.PerformQuack();
            duck.PerformFly();

            duck = new ModelDuck();
            duck.PerformFly();
            duck.DuckFlyBehavior = new FlyRocketPowered();
            duck.PerformFly();

            Console.ReadLine(); // So the console window doesn't close immediately
        }
Ejemplo n.º 18
0
        public void Test1()
        {
            MallardDuck mallard = new MallardDuck();
            RubberDuck  rubber  = new RubberDuck();
            DecoyDuck   decoy   = new DecoyDuck();
            Duck        model   = new ModelDuck();

            mallard.PerformQuack();
            rubber.PerformQuack();
            decoy.PerformQuack();

            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            var mallard = new MallardDuck();
            mallard.PerformFly();
            mallard.PerformQuack();
            mallard.Display();
            mallard.Swim();

            var modelDuck = new ModelDuck();
            modelDuck.Display();
            modelDuck.PerformFly();
            modelDuck.FlyBehaviour = new FlyRocketPowered();
            modelDuck.PerformFly();
            Console.ReadLine();
        }
Ejemplo n.º 20
0
        private static void StrategyPatternRun()
        {
            Console.WriteLine();
            MallardDuck mallard      = new MallardDuck();
            RubberDuck  rubberDuckie = new RubberDuck();
            DecoyDuck   decoy        = new DecoyDuck();

            ModelDuck model = new ModelDuck();

            mallard.PerformQuack();
            rubberDuckie.PerformQuack();
            decoy.PerformQuack();

            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();
        }
Ejemplo n.º 21
0
        public 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();

            IQuackBehavior duckCall = new DuckCall();

            duckCall.quack();
        }
Ejemplo n.º 22
0
        static void Main()
        {
            var mallard = new MallardDuck();

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

            Console.WriteLine();
            Console.WriteLine("--- Dynamic behavior ---");

            var model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();

            Console.ReadKey();
        }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.PerformQuack();
            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();



            Console.ReadKey();

            // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app!
        }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            Console.WriteLine("Simulador de patos");
            Console.WriteLine("------------------");

            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            Console.WriteLine(model.PerformFly());
        }
Ejemplo n.º 25
0
        public void model_duck_cannot_fly()
        {
            Duck model = new ModelDuck();

            Assert.AreEqual("I can't fly.", model.PerformFly());
        }