/// <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); }
/// <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; } }
/// <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); }
public TradeParticipantSimple(string _name) { Name = _name; Wallet = new Wallet(); GoodsStorage = new GoodsStorage(); }