Esempio n. 1
0
 public void addStoreItemOffer(String itemName, int itemsInOffer, int vaitemsPaidForlue)
 {
     if (!storeOffers.ContainsKey(itemName))
     {
         StoreOffer storeOffer = StoreOffer.create(itemsInOffer, vaitemsPaidForlue);
         storeOffers.Add(itemName, storeOffer);
     }
     else
     {
         throw new Exception("Offer already added for this item");
     }
 }
Esempio n. 2
0
        public decimal checkout()
        {
            if (_items.Count <= 0)
            {
                throw new Exception("No item in shopping cart");
            }

            decimal totalPrice = 0;

            //Updated checkout functions accordingly
            Dictionary <string, StoreOffer> itemOffers = _store.GetStoreOffers();

            foreach (StockItem item in _items)
            {
                StoreOffer offer = itemOffers.FirstOrDefault(t => t.Key == item.getItemName()).Value;
                if ((offer == null) || (!offer.isItemFree()))
                {
                    totalPrice += item.getPrice();
                }
            }
            return(totalPrice);
        }