Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //***** DUCKS
            Duck mallard = new MallardDuck();

            mallard.performQuack();
            mallard.performFly();
            mallard.display();
            mallard.setQuackBehaviour(new Squek());
            mallard.performQuack();

            Duck model = new ModelDuck();

            model.performQuack();
            model.display();
            model.setFlyBehavior(new FlyRocketPowered());
            model.performFly();

            Console.ReadKey();

            //***** CHOCOLATE FACTORY

            /*
             * ChocolateBoiler CB = ChocolateBoiler.getInstance();
             * CB.fill();
             * CB.boil();
             *
             * Console.WriteLine("Hello World! Is the chocolate factory boiled? "+ CB.isBoiled());
             * Console.ReadKey();
             */
        }
        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());
        }
Exemplo n.º 3
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());
        }
Exemplo n.º 5
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());
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Duck        modelDuck   = new ModelDuck();
            FlyBehavior flyBehavior = new FlyNoWay();

            modelDuck.FlyBehavior = flyBehavior;
            modelDuck.Fly();
            Console.ReadKey();
        }
Exemplo n.º 8
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());
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            //向上转型
            //Duck mallard = new MallardDuck();
            //mallard.performQuack();
            //mallard.performFly();
            Duck model = new ModelDuck();

            model.performFly();
            model.setFlyBehavior(new FlyRocketPowered());
            model.performFly();
        }
Exemplo n.º 13
0
    public static void Main(string[] args)
    {
        var f    = new FlyWithWings();
        var q    = new Squeak();
        var duck = new ModelDuck(f, q);

        duck.performFly();
        duck.display();
        duck.performQuack();
        //Your code goes here
        Console.WriteLine("Hello, world!");
    }
        public void ModelDuck()
        {
            // Arrange
            var appConsoleOutput = SetupConsoleOutput();
            var modelDuck = new ModelDuck();

            // Act
            TestDuck(modelDuck);

            // Assert
            ApprovalTests.Approvals.Verify(appConsoleOutput);
        }
Exemplo n.º 15
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();
        }
Exemplo n.º 16
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();
        }
Exemplo n.º 17
0
    static void Main(string[] args)
    {
        Duck mallard = new MallardDuck();

        mallard.Quack();
        mallard.Fly();

        Duck model = new ModelDuck();

        model.Fly();
        model.Fly = FlyRocketPowered;
        model.Fly();
    }
Exemplo n.º 18
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();
        }
Exemplo n.º 19
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();

        Duck model = new ModelDuck();

        model.PerformFly();
        model.SetFlyBehaviour(new FlyRocketPowered());
        model.PerformFly();
    }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var modelDuck = new ModelDuck();

            modelDuck.DoFly();

            modelDuck.SetFlyBehavior(new FlyWithWings());
            modelDuck.DoFly();

            Console.ReadLine();
        }
        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();
        }
Exemplo n.º 23
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
        }
Exemplo n.º 25
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());
        }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            Console.WriteLine("Simulating Mullard Duck... \r\n");
            var mallard = new MullardDuck();

            mallard.Quack();
            mallard.Fly();

            Console.WriteLine("\r\nSimulating Model Duck... \r\n");
            var model = new ModelDuck();

            model.Quack();
            model.Fly();
            Console.Read();
        }
Exemplo n.º 27
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();
        }
Exemplo n.º 28
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();
        }
Exemplo n.º 29
0
        public void MiniDuckSimulator()
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

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

            mallard.Quack();
            mallard.Fly();

            DuckBase model = new ModelDuck();

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

            Console.ReadLine();
        }
Exemplo n.º 31
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();
        }
Exemplo n.º 32
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();
        }
Exemplo n.º 33
0
        static void Main(string[] args)
        {
            MallardDuck mallard = new MallardDuck();

            mallard.Quack();
            mallard.SetQuackBehavior(new Squeak());
            Console.WriteLine("-- Change Quack Behavior --");
            mallard.Quack();

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

            var model = new ModelDuck("Model Duck");

            model.Fly();
            model.SetFlyBehavior(new FlyRocketPowered());
            Console.WriteLine("-- Change Quack Behavior --");
            model.Fly();
        }
Exemplo n.º 34
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.performFly();
            // Dynamically update a class at runtime
            model.FlyBehavior = new FlyRocketPowered();
            model.performFly();

            DuckCall duckCall = new DuckCall();

            duckCall.performQuack();
        }
        public void RocketPoweredModelDuck()
        {
            // Arrange
            var appConsoleOutput = SetupConsoleOutput();
            var modelDuck = new ModelDuck();
            var rocketFlying = new FlyRocketPoweredDuck();

            // Assume
            TestDuck(modelDuck);

            // Act
            Console.WriteLine("Giving the duck a rocket pack");
            modelDuck.FlyBehaviour = rocketFlying;
            TestDuck(modelDuck);

            // Assert
            ApprovalTests.Approvals.Verify(appConsoleOutput);
        }