예제 #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");
            }
        }
 public CustomerAOrder()
 {
     _Discount = new Discount50();
 }