コード例 #1
0
 public void AddItem(char c, int itemPrice, ICheckoutSystem checkoutSystem)
 {
   foreach (var specialOffer in _specialOfferItems)
   {
     if (specialOffer.Key == c)
     {
       _specialOfferCounter[c] ++;
       var maxHitCount = specialOffer.Value.Item1;
       var maxCountIsHit = _specialOfferCounter[c] == maxHitCount;
       if (maxCountIsHit)
       {
         var newPrice = specialOffer.Value.Item2;
         var oldPrice = itemPrice * maxHitCount;
         checkoutSystem.SpecialOfferOf(newPrice, oldPrice);
         _specialOfferCounter[c] = 0;
       }
     }
   }
 }