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();
        }
Example #2
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();
        }
Example #3
0
        static void Main(string[] args)
        {
            Duck duck = new MallardDuck();

            PrintMsg(duck);
            sb.AppendLine();


            duck = new RedHeadDuck();
            duck.SetFlyBehavior(Delegation.New <FlyBehavior>(typeof(NoVoice)));
            duck.SetQuackBehavior(new QuackBehavior(typeof(Squeak)));
            PrintMsg(duck);
            sb.AppendLine();

            duck = new RedHeadDuck();
            duck.SetQuackBehavior(new QuackBehavior(typeof(NoVoice)));
            PrintMsg(duck);
            sb.AppendLine();

            duck = new RubberDuck();
            duck.SetFlyBehavior(Delegation.New <FlyBehavior>(typeof(FlyNoWay)));           //new FlyBehavior(typeof(FlyNoWay))
            duck.SetQuackBehavior(new QuackBehavior(typeof(MuteQuack)));
            PrintMsg(duck);
            sb.Append(duck.Swim());
            sb.AppendLine();

            Console.WriteLine(sb.ToString());
            Console.ReadLine();
        }
Example #4
0
        public static void Main(string[] args)
        {
            //A DEPENDENCY INJECTOR OR FACTORY SHOULD REPLACE ALL THIS DECLARATIONS
            IFlyBehavior canFly  = new FlyWithWings();
            IFlyBehavior cantFly = new FlyNoWay();

            IQuackBehavior quack   = new Quack();
            IQuackBehavior squeack = new Squeack();
            IQuackBehavior mute    = new MuteQuack();

            List <Duck> ducks = new List <Duck>();

            Duck mallardDuck = new MallardDuck(canFly, quack);
            Duck redHeadDuck = new RedHeadDuck(canFly, quack);
            Duck decoyDuck   = new DecoyDuck(cantFly, mute);
            Duck rubberDuck  = new RubberDuck(cantFly, squeack);

            ducks.Add(mallardDuck);
            ducks.Add(redHeadDuck);
            ducks.Add(decoyDuck);
            ducks.Add(rubberDuck);

            //NOW WE WILL MAKE OUR DUCKS DISPLAY FLY AND QUACK
            foreach (Duck duck in ducks)
            {
                duck.Display();
                duck.PerformFly();
                duck.PerformQuack();

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

            Console.ReadLine();
        }
Example #5
0
        public static void Main(string[] args)
        {
            BlueHeadDuck obj = new BlueHeadDuck();

            obj.Swim();
            obj.Display();

            RedHeadDuck obj2 = new RedHeadDuck();

            obj2.Swim();
            obj2.Display();

            PlasticDuck obj3 = new PlasticDuck();

            obj3.Swim();
            obj3.Display();
            obj3.PerformFly();


            Console.Read();
        }
Example #6
0
        public static void RevisaoPOO1()
        {
            Duck        duck        = new Duck();
            MallardDuck mallardDuck = new MallardDuck();
            RubberDuck  rubberDuck  = new RubberDuck();
            RedHeadDuck redHeadDuck = new RedHeadDuck();

            duck.display();
            duck.swim();

            mallardDuck.display();
            mallardDuck.quack();
            mallardDuck.fly();

            rubberDuck.display();
            rubberDuck.quack();

            redHeadDuck.display();
            redHeadDuck.fly();
            redHeadDuck.quack();
        }
Example #7
0
        static void Main(string[] args)
        {
            MallardDuck mallard = new MallardDuck();
            RedHeadDuck redHead = new RedHeadDuck();
            RubberDuck  rubber  = new RubberDuck();
            DecoyDuck   decoy   = new DecoyDuck();
            RobotDuck   robot   = new RobotDuck();
            ModelDuck   model   = new ModelDuck();

            PerformDuckFunctions(mallard);
            PerformDuckFunctions(redHead);
            PerformDuckFunctions(rubber);
            PerformDuckFunctions(decoy);
            PerformDuckFunctions(robot);
            PerformDuckFunctions(model);

            model.SetFlyBehaviour(new FlyRocketPowered());
            PerformDuckFunctions(model);

            Console.ReadKey();
        }
Example #8
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    //var context = services.GetRequiredService<AnimalCrossingContext>();
                    DbInitialiser.Initialize(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while seeding the database.");
                }
            }

            FlyWithWing fly   = new FlyWithWing();
            FlyNoWay    noFly = new FlyNoWay();

            MallardDuck md  = new MallardDuck(fly);
            RedHeadDuck red = new RedHeadDuck(fly);
            RubberDuck  rd  = new RubberDuck(noFly);

            md.Display();
            md.Fly();

            red.Display();
            red.Fly();

            rd.Display();
            rd.Fly();

            host.Run();
        }