Exemplo n.º 1
0
        private double CalculateAmountPlusDiscount(Bike bike, int quantity)
        {
            var amountWithDiscount = 0d;

            switch (bike.Price)
            {
                case Bike.OneThousand:
                    if (quantity >= 20)
                        amountWithDiscount += quantity * bike.Price * .9d;
                    else
                        amountWithDiscount += quantity * bike.Price;
                    break;
                case Bike.TwoThousand:
                    if (quantity >= 10)
                        amountWithDiscount += quantity * bike.Price * .8d;
                    else
                        amountWithDiscount += quantity * bike.Price;
                    break;
                case Bike.FiveThousand:
                    if (quantity >= 5)
                        amountWithDiscount += quantity * bike.Price * .8d;
                    else
                        amountWithDiscount += quantity * bike.Price;
                    break;
                case Bike.EightThousand:
                    if (quantity >= 4)
                        amountWithDiscount += quantity * bike.Price * .8d;
                    else
                        amountWithDiscount += quantity * bike.Price;
                    break;
            }

            return amountWithDiscount;
        }
Exemplo n.º 2
0
 public Line(Bike bike, int quantity)
 {
     Bike     = bike;
     Quantity = quantity;
 }
Exemplo n.º 3
0
 public void AddItem(Bike bike, int quantity)
 {
     _orderItems.Add(CreateLineItem(bike, quantity));
 }
Exemplo n.º 4
0
 public Line(Bike bike, int quantity)
 {
     Bike = bike;
     Quantity = quantity;
 }