Example #1
0
        static void Main(string[] args)
        {
            Duck mallardDuck  = new MallardDuck();
            Duck readheadduck = new ReadheadDuck();
            Duck rubberDuck   = new RubberDuck();
            Duck decoyDuck    = new DecoyDuck();
            Duck modelDuck    = new ModelDuck();

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

            readheadduck.Display();
            readheadduck.PerformQuack();
            readheadduck.PerformFly();

            rubberDuck.Display();
            rubberDuck.PerformQuack();
            rubberDuck.PerformFly();

            decoyDuck.Display();
            decoyDuck.PerformQuack();
            decoyDuck.PerformFly();

            modelDuck.Display();
            modelDuck.PerformFly();
            modelDuck.FlyBehavior = new FlyRocketPowered();
            modelDuck.PerformFly();

            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            Duck duck = new MallardDuck();

            duck.Dance();
            duck = new RedHeadDuck();
            duck.Dance();
            duck = new RubberDuck();
            duck.Dance();
            duck = new DecoyDuck();
            duck.Dance();

            duck = new MallardDuck();
            duck.Fly();
            duck.Fly();
            duck.SetFlightBehaviour(new FlyWithWings());
            duck.Fly();
        }
Example #3
0
        static void Main(string [] args)
        {
            MallardDuck mallardDuck = new MallardDuck();

            PlayWithDuck(mallardDuck);
            RedheadDuck redheadDuck = new RedheadDuck();

            PlayWithDuck(redheadDuck);
            RubberDuck rubberDuck = new RubberDuck();

            PlayWithDuck(rubberDuck);
            DecoyDuck decoyDuck = new DecoyDuck();

            PlayWithDuck(decoyDuck);
            ModelDuck modelDuck = new ModelDuck();

            PlayWithDuck(modelDuck);
            modelDuck.SetFlyBehavior(FlyBehavior.FlyWithWingsAction());
            PlayWithDuck(modelDuck);
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("MullardDuck");
            Duck mallard = new MullardDuck();

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

            Console.WriteLine();
            Console.WriteLine("RubberDuck");
            Duck rubberDuck = new RubberDuck();

            rubberDuck.Quack();

            rubberDuck.setQuackBehavior(new Behaviors.MuteQuack());
            rubberDuck.Quack();

            Console.WriteLine();
            Console.WriteLine("DecoyDuck");
            Duck decoyDuck = new DecoyDuck();

            decoyDuck.Swim();
        }