Example #1
0
        private AuctionCommand ProcessCloseEvent()
        {
            if (Snapshot.State == SniperState.Winning)
            {
                Snapshot = Snapshot.Won();
            }
            else
            {
                Snapshot = Snapshot.Lost();
            }

            return(AuctionCommand.None());
        }
Example #2
0
        private AuctionCommand ProcessPriceEvent(int currentPrice, int increment, string bidder)
        {
            if (Bidder == bidder)
            {
                Snapshot = Snapshot.Winning(currentPrice);
                return(AuctionCommand.None());
            }

            int newBid = currentPrice + increment;

            if (newBid > StopPrice)
            {
                Snapshot = Snapshot.Losing(currentPrice);
                return(AuctionCommand.None());
            }
            else
            {
                Snapshot = Snapshot.Bidding(currentPrice, newBid);
                return(AuctionCommand.Bid(newBid));
            }
        }
Example #3
0
 private AuctionCommand ProcessUnknownEvent()
 {
     Snapshot = Snapshot.Failed();
     return(AuctionCommand.None());
 }
Example #4
0
 public AuctionSniper(string bidder, int stopPrice)
 {
     Bidder    = bidder;
     StopPrice = stopPrice;
     Snapshot  = SniperSnapshot.Joining();
 }