Exemple #1
0
        private int getBetAmount(ISnail pickToWin, int money)
        {
            int wager = 0;
            bool inputValid = false;

            this.printBetPrompt(pickToWin, money, null);

            Console.CursorVisible = true;
            inputValid = int.TryParse(Console.ReadLine(), out wager);

            while (wager <=0 || wager > money)
            {
                if (!inputValid)
                {
                    this.printBetPrompt(pickToWin, money, "You must enter a number!\n");
                }
                else if (wager <= 0)
                {
                    this.printBetPrompt(pickToWin, money, "You must bet at least $1.\n");
                }
                else
                {
                    this.printBetPrompt(pickToWin, money, "You don't have that much money!\n");
                }
                inputValid = int.TryParse(Console.ReadLine(), out wager);
            }
            Console.CursorVisible = false;

            return wager;
        }
Exemple #2
0
        public Race(int length, IDictionary<ISnail, IEnumerable<int>> positions)
        {
            this.length    = length;
            this.positions = positions;

            winner = (from pair in positions
                      where pair.Value.Last() == positions.Max(snail => snail.Value.Last())
                      select pair).First().Key;
        }
Exemple #3
0
 public Bet(ISnail pick, int wager)
 {
     this.pickToWin   = pick;
     this.wagerAmount = wager;
 }
Exemple #4
0
 private void printBetPrompt(ISnail pickToWin, int money, string additionalText)
 {
     using (IOutputMethod view = createView())
     {
         view.Write("\n\n");
         if (additionalText != null)
         {
             view.Write(this.leftMargin + additionalText + "\n");
         }
         view.Write(this.leftMargin + "You have ${0}.\n\n", money);
         view.Write(this.leftMargin + "How many dollars would you like to bet on {0}? ", pickToWin.Name);
     }
 }