public Buyer(string buyerName, int maximumPrice, int numberToBuy) { BuyerName = buyerName; NumberToBuy = numberToBuy; MaximumPrice = maximumPrice; Snapshot = BuyerSnapshot.Joining(); }
private StockCommand ProcessPurchaseEvent(string buyerName, int numberSold) { if (BuyerName == buyerName) { Snapshot = Snapshot.Bought(numberSold); if (Snapshot.BoughtSoFar >= NumberToBuy) { Snapshot = Snapshot.Closed(); } } return(StockCommand.None()); }
private StockCommand ProcessPriceEvent(int currentPrice, int numberInStock) { if (currentPrice > MaximumPrice) { Snapshot = Snapshot.Monitoring(currentPrice, numberInStock); return(StockCommand.None()); } Snapshot = Snapshot.Buying(currentPrice, numberInStock); int numberToBuy = Math.Min(numberInStock, NumberToBuy); return(StockCommand.Buy(currentPrice, numberToBuy)); }
private StockCommand ProcessCloseEvent() { Snapshot = Snapshot.Closed(); return(StockCommand.None()); }