Exemplo n.º 1
0
        public double calculateDiscount(cart MyShoppingCart)
        {
            double discount = 0;

            foreach (var Discount in MyShoppingCart.Discounts)
            {
                if (Discount.Type == DiscountType.noDiscount)
                {
                    discount += 0.0;
                }

                if (Discount.Type == DiscountType.perCart)
                {
                    discount += calTotal.calculateTotal(MyShoppingCart) * Discount.Percentage;
                }

                foreach (var item in MyShoppingCart.Items)
                {
                    if (Discount.Type == DiscountType.perItem && item.HasDiscount)
                    {
                        discount += item.Item.Price * item.Discount * item.Quantity;
                    }
                    else if (Discount.Type == DiscountType.perType && item.HasDiscount)
                    {
                        discount += item.Item.Price * item.Discount;
                    }
                }
            }
            return(discount);
        }
Exemplo n.º 2
0
        public double calculateTotal(cart myShoppingCart)
        {
            double total = 0;

            foreach (var item in myShoppingCart.Items)
            {
                total += item.Item.Price * item.Quantity;
            }
            return(total);
        }
Exemplo n.º 3
0
        public double calculateTaxes(cart MyShoppingCart)
        {
            double taxes = 0;

            foreach (var item in MyShoppingCart.Items)
            {
                taxes += item.Item.Price * item.Item.Taxe * item.Quantity;
            }
            return(taxes);
        }
Exemplo n.º 4
0
        public double calculatePayment(cart MyShoppingCart)
        {
            double bills = calTotal.calculateTotal(MyShoppingCart) + calTaxes.calculateTaxes(MyShoppingCart) - calDiscount.calculateDiscount(MyShoppingCart);

            return(bills * exRate.ExchangeCurrency(MyShoppingCart.Currency));
        }
Exemplo n.º 5
0
 public void AddDiscount(cart MyShoppingCart, discount discount)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public List <cartItem> GetItems(cart MyShoppingCart)
 {
     return(MyShoppingCart.Items);
 }
Exemplo n.º 7
0
 public void AddItem(cart MyShoppingCart, cartItem item)
 {
     MyShoppingCart.Items.Add(item);
 }