Example #1
0
        /// <summary>
        /// Use strategy pattern: When you want to define d a class that will have one behaviour that is similar to other behaviour in a list
        /// Advantages:
        /// -Reduces long list of conditionals
        /// -Avaoid duplicate code
        /// -Keeps class changes from forcing other class changes
        /// -Can hide complicated  secret code from the user
        /// Disadvantage:
        /// -Increased number of object/ classes
        /// </summary>
        private static void ExecuteStrategyDesignPattern()
        {
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("STRATEGY PATTERN \n");
            Console.ForegroundColor = ConsoleColor.White;

            Booking hotel  = new HotelBooking(new Traveller("Papa", "Bengu"));
            Booking flight = new FlightBooking(new Traveller("Dikeledi", "Ngqwemla"));


            Console.WriteLine(hotel.ToString());
            Console.WriteLine("");
            Console.WriteLine(flight.ToString());

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