Beispiel #1
0
        static void Main(string[] args)
        {
            // Pato Bravo
            MallardDuck md = new MallardDuck();

            md.Display();
            md.Swim();
            md.Fly();
            md.Quack();
            System.Console.WriteLine("\n");

            // Pato Cabeça-vermelha
            RedHeadDuck rhd = new RedHeadDuck();

            rhd.Display();
            rhd.Swim();
            rhd.Fly();
            rhd.Quack();
            System.Console.WriteLine("\n");

            // Pato de Borracha
            RubberDuck rd = new RubberDuck();

            rhd.Display();
            rhd.Swim();
            rd.Quack(); // Chia invés de grasnar
            System.Console.WriteLine("\n");

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            // Pato Bravo
            MallardDuck md = new MallardDuck();
            md.Display();
            md.Swim();
            md.Fly();
            md.Quack();
            System.Console.WriteLine("\n");

            // Pato Cabeça-vermelha
            RedHeadDuck rhd = new RedHeadDuck();
            rhd.Display();
            rhd.Swim();
            rhd.Fly();
            rhd.Quack();
            System.Console.WriteLine("\n");

            // Pato de Borracha
            RubberDuck rd = new RubberDuck();
            rhd.Display();
            rhd.Swim();
            rd.Quack(); // Chia invés de grasnar
            System.Console.WriteLine("\n");

            Console.ReadKey();
        }
Beispiel #3
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();
        }
Beispiel #4
0
        public void TestMethod1()
        {
            IFlyBehaviour flyBehaviour = new FlyBehaviour();

            MallardDuck mallardDuck = new MallardDuck(flyBehaviour);
            RedheadDuck redheadDuck = new RedheadDuck(flyBehaviour);

            IFlyBehaviour noFlyBehaviour = new NoFlyBehaviour();
            RubberDuck    rubberDuck     = new RubberDuck(noFlyBehaviour);


            mallardDuck.Display();
            mallardDuck.Fly();

            redheadDuck.Display();
            redheadDuck.Fly();

            rubberDuck.Display();
            rubberDuck.Fly();

            rubberDuck.ChangeFlyBehaviour(flyBehaviour);
            rubberDuck.Fly();

            redheadDuck.Swim();
            mallardDuck.Swim();
            rubberDuck.Swim();
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.Swim();
            mallard.PerformQuack();
            mallard.PerformFly();
        }
Beispiel #6
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();
        }
        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();
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            var mallardDuck = new MallardDuck();

            mallardDuck.QuackBehavior = new QuackAsNormal();
            mallardDuck.FlyBehavior   = new FlyWithWings();
            Console.WriteLine($"Mallard duck {new string('-', 50)}");
            mallardDuck.Swim();
            mallardDuck.PerformQuack();
            mallardDuck.PerformFly();

            var redheadDuck = new RedheadDuck();

            redheadDuck.QuackBehavior = new QuackAsNormal();
            redheadDuck.FlyBehavior   = new FlyWithWings();
            Console.WriteLine($"Redhead duck {new string('-', 50)}");
            redheadDuck.Swim();
            redheadDuck.PerformQuack();
            redheadDuck.PerformFly();

            var rubberDuck = new RubberDuck();

            rubberDuck.QuackBehavior = new Sqeak();
            rubberDuck.FlyBehavior   = new FlyNoWay();
            Console.WriteLine($"Rubber duck {new string('-', 50)}");
            rubberDuck.Swim();
            rubberDuck.PerformQuack();
            rubberDuck.PerformFly();

            var decoyDuck = new DecoyDuck();

            decoyDuck.QuackBehavior = new Mute();
            decoyDuck.FlyBehavior   = new FlyNoWay();
            Console.WriteLine($"Decoy duck {new string('-', 50)}");
            decoyDuck.Swim();
            decoyDuck.PerformQuack();
            decoyDuck.PerformFly();
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            var md = new MallardDuck();

            Console.WriteLine(md.Display() + "#" + md.Swim() + "#" + md.FlyBehavior.Fly() + "#" + md.QuackBehavior.Quack());
        }
        public void mallard_duck_can_swim()
        {
            Duck mallard = new MallardDuck();

            Assert.AreEqual("All ducks float, even decoys!", mallard.Swim());
        }