public void Purchase(Juice kind) { Juice commodity = _controller.Purchase(kind); if (!(commodity == null)) { CommodityTray.Add(commodity); } //ここで最も安い商品と比較して、ReturnChange()を呼び出すことも可能 }
public bool HasStock(Juice kind) { //if (kind == Juice.RedBull) //{ // //return RedBullBin.Stock > 0; //暫定 // return RedBullBin[0].Stock > 0; //} //return Bin.Stock > 0; return GetBin(kind).Stock > 0; }
public Bin GetBin(Juice kind) { Bin bin = BinList.Find(b => (b.Commodity == kind)); if (bin == null) { bin = new Bin() { Commodity = kind, }; BinList.Add(bin); } return bin; }
public Juice Purchase(Juice kind) { if (!IsPurchasable(kind)) { return null; } Juice product = _rack.Supply(kind); _coinMech.GetCharge(kind.Price); return product; }
public bool IsPurchasable(Juice kind) { if (_coinMech.Deposit < kind.Price) { return false; } if (!_rack.HasStock(kind)) //←追加 { return false; } return true; }
public Juice Supply(Juice kind) { //Bin.Stock--; //後で消す GetBin(kind).Stock--; return kind; }
public void AddStock(Juice kind, int number) { //RedBullBin.Stock += number; //暫定 //RedBullBin[0].Stock += number; GetBin(kind).Stock += number; }
public int GetStock(Juice kind) { return _rack.GetBin(kind).Stock; }
public void AddStock(Juice kind, int number) { _rack.AddStock(kind, number); }