Beispiel #1
0
        static void Main(string[] args)
        {
            ShoppingMall shoppingMall = new ShoppingMall(null);

            shoppingMall.CustomerName  = $"{DateTime.Now.DayOfWeek.ToString()} customer";
            shoppingMall.BillingAmount = 1000;

            switch (DateTime.Now.DayOfWeek)
            {
            case DayOfWeek.Monday:
            case DayOfWeek.Tuesday:
            case DayOfWeek.Wednesday:
                shoppingMall.CurrentStrategy = new LowDiscountStrategy();
                break;

            case DayOfWeek.Thursday:
            case DayOfWeek.Friday:
                shoppingMall.CurrentStrategy = new HighDiscountStrategy();
                break;

            case DayOfWeek.Saturday:
            case DayOfWeek.Sunday:
                shoppingMall.CurrentStrategy = new NoDiscountStrategy();
                break;

            default:
                shoppingMall.CurrentStrategy = new NoDiscountStrategy();
                break;
            }

            Console.WriteLine($"Final Bill is : {shoppingMall.GetFinalBill()}");
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ShoppingMall shopping = new ShoppingMall(null);

            shopping.CustomerName = "Arvind D C";
            shopping.BillAmount   = 1000;

            switch (DateTime.Now.DayOfWeek)
            {
            case DayOfWeek.Monday:
                shopping.CurrentStrategy = new LowDiscount();
                break;

            case DayOfWeek.Tuesday:
                shopping.CurrentStrategy = new HighDiscount();
                break;

            default: shopping.CurrentStrategy = new NoDiscountStrategy();
                break;
            }

            Console.WriteLine("Dear {0}, Total Bill Amount after Discount is  {1}", shopping.CustomerName, shopping.GetFinalBill());

            Console.ReadKey();
        }