Example #1
0
        public void ShowWishListPrice()
        {
            this.ShowAllWish();
            Console.WriteLine("Enter Wish list id:");

            string wishIdString = Console.ReadLine().Trim();

            WishDTO wish = this.wishService.GetSingleWish(wishIdString);

            if (wish != null)
            {
                double totalWishPrice = 0;
                foreach (ProductDTO product in wish.Items)
                {
                    totalWishPrice += product.Price;
                }

                Console.WriteLine("Enter discout codes, seperated by spaces");
                string discountKeys           = Console.ReadLine().Trim();
                IDecoratorComponent decorator = wish;
                foreach (string coupon in discountKeys.Split(" "))
                {
                    if (coupon != "")
                    {
                        if (this.coupons.ContainsKey(coupon))
                        {
                            if (coupon == "drop10")
                            {
                                decorator = new Discount10(decorator);
                                //Helper.MyPrint(decorator.GetPrice().ToString());
                            }
                            else if (coupon == "drop20")
                            {
                                decorator = new Discount20(decorator);
                                //Helper.MyPrint(decorator.GetPrice().ToString());
                            }
                            else if (coupon == "drop50")
                            {
                                decorator = new Discount50(decorator);
                                //Helper.MyPrint(decorator.GetPrice().ToString());
                            }
                        }
                        else
                        {
                            Helper.MyPrint($"Error: {coupon} doesn't exist.", "r");
                        }
                    }
                }
                //decorator = new Discount(wish);
                Helper.MyPrint($"Your total wish will cost {decorator.GetPrice()} taka.", "g");
            }
        }
Example #2
0
 public Discount(IDecoratorComponent component)
 {
     this.Component = component;
 }
Example #3
0
 static void Display(string s, IDecoratorComponent c)
 {
     Console.WriteLine(s + c.Operation());
 }
Example #4
0
 public Discount50(IDecoratorComponent component) : base(component)
 {
     //Console.WriteLine("Drop 50");
 }
Example #5
0
 public DecoratorB(IDecoratorComponent c)
 {
     component = c;
 }