Exemple #1
1
 static void Main(string[] args)
 {
     Duck mallard = new MallardDuck();
     mallard.PerformQuack();
     mallard.PerformFly();
     Console.ReadLine();
 }
    // Use this for initialization
    void Start()
    {
        Duck millard = new MallardDuck();

        millard.PerformQuack();
        millard.PerformFly();

        millard.SetFlyBehavior(new FlyNoWay());
        millard.SetQuackBehavior(new MuteQuack());

        millard.PerformQuack();
        millard.PerformFly();
    }
Exemple #3
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();
        }
        public void MallardDuckTest()
        {
            Duck mallard = new MallardDuck();

            Assert.Equal("I'm flying!", mallard.PerformFly());
            Assert.Equal("Quack!", mallard.PerformQuack());
        }
Exemple #5
0
        public static void Start()
        {
            Duck mallard = new MallardDuck(new FlyWithWings(), new SimpleQuack());

            mallard.PerformQuack();
            mallard.PerformFly();
        }
Exemple #6
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 mainTest()
        {
            Duck mallard = new MallardDuck();

            mallard.PerformFly();
            mallard.PerformQuack();
        }
Exemple #8
0
        private static void Main()
        {
            var mallardDuck = new MallardDuck();

            mallardDuck.Display();
            mallardDuck.PerformQuack();
            mallardDuck.Swim();
            mallardDuck.PerformFly();
            Console.WriteLine();

            var redheadDuck = new RedheadDuck();

            redheadDuck.Display();
            redheadDuck.PerformQuack();
            redheadDuck.Swim();
            redheadDuck.PerformFly();
            Console.WriteLine();

            var rubberDuck = new RubberDuck();

            rubberDuck.Display();
            rubberDuck.PerformQuack();
            rubberDuck.Swim();
            rubberDuck.PerformFly();
            Console.WriteLine();

            var decoyDuck = new DecoyDuck();

            decoyDuck.Display();
            decoyDuck.Swim();
            Console.WriteLine();

            Console.Write("Press Enter to exit ...");
            Console.ReadLine();
        }
Exemple #9
0
        public void MarllardDuckTest()
        {
            var duck = new MallardDuck();

            duck.PerformFly();
            duck.PerformQuack();
            duck.Display();
        }
Exemple #10
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.Swim();
            mallard.PerformQuack();
            mallard.PerformFly();
        }
        public void TestMallardDuck()

        {
            HeadFirstDesignPatterns.Strategy.Duck.Duck Mallard = new MallardDuck();

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

            Assert.AreEqual("I'm flying!!", Mallard.PerformFly());
        }
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello World!");

            Duck mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();
        }
        public static void Main(string[] args)
        {
            Duck mallardDuck = new MallardDuck();

            mallardDuck.PerformFly();
            mallardDuck.PerformQuack();

            mallardDuck.SetFlyBehaviour(new RocketFly());
            mallardDuck.PerformFly();
        }
Exemple #14
0
        static void Main(string[] args)
        {
            // Duck
            var mallard = new MallardDuck();

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

            Console.ReadLine();
        }
Exemple #15
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Duck mallard = new MallardDuck();

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

            mallard.SetFlyBehaviour(new FlyNoWay());
            mallard.PerformFly();
        }
Exemple #16
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

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

            Console.WriteLine("===");

            Duck model = new ModelDuck();

            model.Display();
            mallard.PerformQuack();
            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();

            Console.ReadKey();
        }
Exemple #17
0
        public static void Test_1()
        {
            var mallardDuck = new MallardDuck();

            mallardDuck.Display();
            mallardDuck.PerformFly();
            mallardDuck.SetFlyBehavior(new FlyNoWay());
            mallardDuck.PerformFly();
            mallardDuck.PerformQuack();
            mallardDuck.SetFlyBehavior(new FlyLikeRocket());
            mallardDuck.PerformFly();
        }
Exemple #18
0
        static void Main(string[] args)
        {
            Console.WriteLine("Create Mallard Duck");
            Console.WriteLine();

            Duck duck = new MallardDuck();

            duck.Display();
            duck.PerformQuack();
            duck.PerformFly();
            duck.Swim();
            Console.WriteLine();

            Console.WriteLine("Change the state");
            Console.WriteLine();
            duck.SetFlyBehavior(new FlyRocketPowered());
            duck.SetQuackBehavior(new MuteQuack());
            duck.Display();
            duck.PerformQuack();
            duck.PerformFly();
            duck.Swim();
        }
Exemple #19
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();
        }
    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();
    }
Exemple #21
0
        public void Test2()
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();
        }
        public static void Main()
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
Exemple #23
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();
        }
        public static void Run()
        {
            Duck mallard = new MallardDuck();

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

            Duck model = new ModelDuck();

            model.PerformFly();
            model.flyBehavior = new FlyRockedPowered();
            model.PerformFly();
        }
        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
        }
        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());
        }
        public void DuckSimulatorTest()
        {
            var mallardDuck = new MallardDuck(new FlyWithWings(), new Quack());

            mallardDuck.Display();
            mallardDuck.PerformFly();
            mallardDuck.PerformQuack();

            //Dynamically change behavior
            mallardDuck.ChangeFlyBehaviour(new FlyRocketPower());
            mallardDuck.PerformFly();


            Assert.True(true);
        }
        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();
        }
Exemple #30
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();
        }
Exemple #31
0
        static void Main(string[] args)
        {
            Duck duck = new MallardDuck();

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

            Duck model = new DecoyDuck();

            model.Display();
            model.PerformFly();
            model.SetFlyBehavior(new FlyWithWings());
            model.PerformFly();

            Console.ReadLine();
        }
        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();
        }
Exemple #33
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();
        }
        static void Main(string[] args)
        {
            IFlyBehavior   flyBehavior   = new FlyBehavior.FlyBehavior();
            IQuackBehavior quackBehavior = new QuackBehavior.QuackBehavior();

            MallardDuck mallardDuck = new MallardDuck(quackBehavior, flyBehavior);

            mallardDuck.PerformFly();
            mallardDuck.PerformQuack();

            IFlyBehavior   flyBehaviorNoFly     = new FlyNoWayBehavior();
            IQuackBehavior quackBehaviorNoQuack = new MuteQuackBehavior();

            MallardDuck mallardDuckSpecial = new MallardDuck(quackBehaviorNoQuack, flyBehaviorNoFly);

            mallardDuckSpecial.PerformFly();
            mallardDuckSpecial.PerformQuack();
        }