Exemple #1
0
        static void Main(string[] args)
        {
            // This example takes the bill amount and calculates the final bill as per the discounted strategy

            BillCalculateStrategy strategy = null;

            var currentDay = System.DateTime.Now.DayOfWeek;

            var customerBillAmount = 1000;

            if(currentDay == DayOfWeek.Sunday || currentDay == DayOfWeek.Saturday)
            {
                strategy = new DiscountStrategy();
            }
            else
            {
                strategy = new NoDiscountStrategy();
            }

            var finalBillAmount = strategy.CalculateFinalBill(customerBillAmount);
            Console.WriteLine("your final bill amount is {0}",finalBillAmount);
            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            // This example takes the bill amount and calculates the final bill as per the discounted strategy

            BillCalculateStrategy strategy = null;

            var currentDay = System.DateTime.Now.DayOfWeek;

            var customerBillAmount = 1000;

            if (currentDay == DayOfWeek.Sunday || currentDay == DayOfWeek.Saturday)
            {
                strategy = new DiscountStrategy();
            }
            else
            {
                strategy = new NoDiscountStrategy();
            }

            var finalBillAmount = strategy.CalculateFinalBill(customerBillAmount);

            Console.WriteLine("your final bill amount is {0}", finalBillAmount);
            Console.ReadKey();
        }