コード例 #1
0
 /// <summary>
 /// Проверяем наличие товара
 /// </summary>
 /// <param name="sellItem"></param>
 /// <returns></returns>
 private bool ChechGoodsIsEnough(GoodsItem sellItem)
 {
     if (GoodsStorage.GetItem(a => a.Equals(sellItem)) != null)
     {
         return(true);
     }
     return(false);
 }
コード例 #2
0
 /// <summary>
 /// Выдаем товар
 /// </summary>
 /// <param name="goodItem"></param>
 /// <param name="customer"></param>
 public virtual void TakeTheGood(GoodsItem goodItem, Customer customer)
 {
     if (customer.GetTheGood(goodItem))
     {
         GoodsStorage.RemoveItems(a => a.Equals(goodItem));
         DBalance = 0;
     }
 }
コード例 #3
0
        /// <summary>
        /// продаем товар
        /// </summary>
        /// <param name="sellItem"></param>
        /// <param name="customer"></param>
        /// <returns></returns>
        private bool _SellTheItem(GoodsItem sellItem, Customer customer)
        {
            List <Coin> change;

            if (customer.GetTheGood(sellItem))
            {
                GoodsStorage.RemoveItems(a => a == sellItem);
                change = CountChange(sellItem, DBalance);
            }
            else
            {
                change = CountChange(null, DBalance);
            }
            if (customer.GetCoins(change))
            {
                Wallet.RemoveItems(a => change.Contains(a));
                DBalance = 0;
                NewMessage("Thank you!");
                return(true);
            }
            return(false);
        }
コード例 #4
0
 public TradeParticipantSimple(string _name)
 {
     Name         = _name;
     Wallet       = new Wallet();
     GoodsStorage = new GoodsStorage();
 }