Esempio n. 1
0
 public Buyer(string buyerName, int maximumPrice, int numberToBuy)
 {
     BuyerName    = buyerName;
     NumberToBuy  = numberToBuy;
     MaximumPrice = maximumPrice;
     Snapshot     = BuyerSnapshot.Joining();
 }
Esempio n. 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());
 }
Esempio n. 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));
        }
Esempio n. 4
0
 private StockCommand ProcessCloseEvent()
 {
     Snapshot = Snapshot.Closed();
     return(StockCommand.None());
 }