Exemple #1
0
 public Buyer(string buyerName, int maximumPrice, int numberToBuy)
 {
     BuyerName    = buyerName;
     NumberToBuy  = numberToBuy;
     MaximumPrice = maximumPrice;
     Snapshot     = BuyerSnapshot.Joining();
 }
Exemple #2
0
 private StockCommand ProcessPurchaseEvent(string buyerName, int numberSold)
 {
     if (BuyerName == buyerName)
     {
         Snapshot = Snapshot.Bought(numberSold);
         if (Snapshot.BoughtSoFar >= NumberToBuy)
         {
             Snapshot = Snapshot.Closed();
         }
     }
     return(StockCommand.None());
 }
Exemple #3
0
        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));
        }
Exemple #4
0
 private StockCommand ProcessCloseEvent()
 {
     Snapshot = Snapshot.Closed();
     return(StockCommand.None());
 }