Beispiel #1
0
        static void Main(string[] args)
        {
            IWalkBehavior walkBehavior = new WalkBehaviorD();
            IDuck         duck         = new WildDuck(walkBehavior);
            IDuck         cityDuck     = new CityDuck();
            IDuck         mountainDuck = new MountainDuck();
            IDuck         cloudDuck    = new CloudDuck();

            Console.WriteLine(duck.Fly());
            Console.WriteLine(cityDuck.Fly());
            Console.WriteLine(mountainDuck.Fly());
            Console.WriteLine(mountainDuck.Fly());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            WildDuck duck = new WildDuck(new DuckFlying(), new WildDuckQuacking());

            duck.MakeFly();
            duck.MakeQuack();
            HomeDuck hd = new HomeDuck();

            hd.MakeFly();
            hd.MakeQuack();
            hd.Display();
            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Duck jungleDuck = new WildDuck(new DisplayingGraphically(), new HighFlying(), new LoudQuacking());

            jungleDuck.Fly();
            jungleDuck.Display();
            jungleDuck.Quack();

            Duck cityDuck = new RubberDuck(new DisplayingText(), new GroundFlying(), new NoQuacking());

            cityDuck.Fly();
            cityDuck.Display();
            cityDuck.Quack();
            Console.ReadLine();
        }
Beispiel #4
0
        public static void Main(string[] args)
        {
            WildDuck wildDuck = new WildDuck();

            wildDuck.Quack();
            wildDuck.Fly();

            RubberDuck rubberDuck = new RubberDuck();

            rubberDuck.Quack();
            rubberDuck.Fly();
            rubberDuck.Flying = new Flying();
            rubberDuck.Fly();


            Console.ReadLine();
        }
        /// <summary>
        /// Definition:
        /// The strategy pattern defines a family of algorithms, encapsulates each one and makes them interchangeable.
        /// Strategy lets the algorithm very independently from clients that use it.
        /// </summary>
        static void Main(string[] args)
        {
            WildDuck wildDuck = new WildDuck();
            CityDuck cityDuck = new CityDuck();

            Console.WriteLine("\n--- The wild duck ---");
            wildDuck.Quack();
            wildDuck.Fly();
            wildDuck.Display();

            Console.WriteLine("\n--- The city duck ---");
            cityDuck.Quack();
            cityDuck.Fly();
            cityDuck.Display();


            Console.ReadKey();
        }