static void Main(string[] args)
        {
            Duck myduck = new MallardDuck();

            myduck.display();
            myduck.performFly();
            myduck.performQuack();

            myduck = new RedHeadDuck();
            myduck.display();
            myduck.performFly();
            myduck.performQuack();

            myduck = new RubberDuck();
            myduck.display();
            myduck.performFly();
            myduck.performQuack();

            myduck = new DecoyDuck();
            myduck.display();
            myduck.performFly();
            myduck.performQuack();

            myduck.setFlyBehavior(new FlyJet());
            myduck.performFly();
        }
Example #2
0
        static void Main(string[] args)
        {
            DuckBase duck1 = new MallardDuck("Mallard Duck");

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

            DuckBase duck2 = new DecoyDuck("Decoy Duck");

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

            DuckBase duck3 = new RubberDuck("Rubber Duck");

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

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

            Duck model = new ModelDuck();

            model.Display();
            model.PerformQuack();
            model.PerformFly();
            model.SetFlyBehaviour(new FlyRocketPowered());
            model.PerformFly();
            Console.WriteLine();

            Duck decoy = new DecoyDuck();

            decoy.Display();
            decoy.PerformQuack();
            decoy.PerformFly();
            decoy.SetQuackBehaviour(new Squeak());
            Console.WriteLine();

            Duck rubber = new RubberDuck();

            rubber.Display();
            rubber.PerformQuack();
            rubber.PerformFly();
            rubber.Swim();
            Console.WriteLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            Duck num1 = new MallardDuck();

            num1.display();
            num1.performFly();
            num1.performQuack();
            num1.Swim();

            Duck num2 = new RedheadDuck();

            num2.display();
            num2.performFly();
            num2.performQuack();
            num2.Swim();

            Duck num3 = new DecoyDuck();

            num3.display();
            num3.performFly();
            num3.performQuack();
            num3.Swim();
            num3.setFlyBehavior(new FlyWithWings());
            num3.performFly();

            Console.Read();
        }
Example #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("These three ducks may give you a good day!\n");
            Duck duck1 = new MallardDuck();
            Duck duck2 = new RubberDuck();
            Duck duck3 = new DecoyDuck();

            DisplayProperties(duck1);
            DisplayProperties(duck2);
            DisplayProperties(duck3);

            Console.ReadLine();
        }
Example #6
0
        static void Main(string[] args)
        {
            Duck Mallard = new MallardDuck();

            Mallard.Display();
            Mallard.PerformQuack();
            Mallard.PerformFly();

            Duck Model = new ModelDuck();

            Console.WriteLine();
            Model.Display();
            Model.PerformQuack();
            Model.PerformFly();
            Model.SetFlyBehavior(new FlyRocketPowered());
            Model.PerformFly();

            Duck Redhead = new RedheadDuck();

            Console.WriteLine();
            Redhead.Display();
            Redhead.PerformQuack();
            Redhead.PerformFly();

            Duck Rubber = new RubberDuck();

            Console.WriteLine();
            Rubber.Display();
            Rubber.PerformQuack();
            Rubber.PerformFly();

            Duck Decoy = new DecoyDuck();

            Console.WriteLine();
            Decoy.Display();
            Decoy.PerformQuack();
            Decoy.PerformFly();
        }
Example #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("We have four ducks available for the showcase.");
            Console.WriteLine("Choose one of these and type the number. ex) 1 = DecoyDuck");
            Console.WriteLine("");
            Console.WriteLine("1. DecoyDuck");
            Console.WriteLine("2. MallardDuck");
            Console.WriteLine("3. RedheadDuck");
            Console.WriteLine("4. RubberDuck");
            Console.WriteLine("");

            string end = String.Empty;

            do
            {
                Duck duck = default(Duck);

                string s = Console.ReadLine();
                if (!String.IsNullOrEmpty(s) && int.TryParse(s, out int result))
                {
                    switch (result)
                    {
                    case 1:
                    {
                        duck = new DecoyDuck();
                        duck.setFlyBehavior(new FlyNoWay());
                        duck.setQuackHeavior(new MuteQuack());
                    }
                    break;

                    case 2:
                    {
                        duck = new MallardDuck();
                        duck.setFlyBehavior(new FlyWithWings());
                        duck.setQuackHeavior(new StrategyPattern.Quack.Quack());
                    }
                    break;

                    case 3:
                    {
                        duck = new RedheadDuck();
                        duck.setFlyBehavior(new FlyWithWings());
                        duck.setQuackHeavior(new Squeak());
                    }
                    break;

                    case 4:
                    {
                        duck = new RubberDuck();
                        duck.setFlyBehavior(new FlyNoWay());
                        duck.setQuackHeavior(new MuteQuack());
                    }
                    break;

                    default:
                    {
                        Console.WriteLine("You choose a duck that is not on the list. I'm gonna just show you a rubber duck !");

                        duck = new RubberDuck();
                        duck.setFlyBehavior(new FlyNoWay());
                        duck.setQuackHeavior(new MuteQuack());
                    }
                    break;
                    }
                }
                else
                {
                    Console.WriteLine("Input only numbers. Don't type their names.");
                }

                duck.display();
                duck.performFly();
                duck.performQuack();
                duck.swim();

                end = Console.ReadLine();
            } while (end != "exit");
        }