/// <summary> /// Event that triggers when a shop needs to restock /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Item_LowStockReached(object sender, LowStockReachedEventArgs e) { // Logic to get a vehicle to simulate traveling to the shop Shop s = (Shop)sender; s.Stock = s.Capacity; }
public int Sell(int demand) { if (demand > Stock) /// <param name="demand"></param> { demand = Stock; } this.stock -= demand; tempSold += demand; if (Stock <= RestockAmount) { LowStockReachedEventArgs args = new LowStockReachedEventArgs(); args.TimeReached = DateTime.Now; OnLowStockReached(args); } return(demand); //AMOUNT THAT HAS BEEN SOLD }
/// <summary> /// Event that triggers when the stock is low /// </summary> /// <param name="e"></param> public virtual void OnLowStockReached(LowStockReachedEventArgs e) { LowStockReached?.Invoke(this, e); }