コード例 #1
0
 public void bet(Croupier croupier, int amount)
 {
     if (this.Cash >= amount)
     {
         this.Cash -= amount;
         croupier.betEven(this, amount);
     }
     else
     {
         throw new OutOfCashException();
     }
 }
コード例 #2
0
        private static void SimulateMartingale(int amount, int winningCondition)
        {
            Gambler  gambler  = new Gambler(30000);
            Croupier croupier = new Croupier(new Roulette());

            //amount = 100;
            //winningCondition = 5000;

            try
            {
                while (gambler.Cash < winningCondition)
                {
                    gambler.bet(croupier, amount);
                    croupier.spinRoulette();
                    croupier.equalize();

                    /*        if (croupier.getRouletteNumber()%2 == 0)
                     *      {
                     *          amount = 10;
                     *          //Console.WriteLine("player won: " + gambler.Cash);
                     *      }
                     *      else
                     *      {
                     *          amount *= 2;
                     *          //Console.WriteLine("player lost: " + gambler.Cash);
                     *      }*/
                }
                Program.playerWins++;
                //Console.Write(".");
                //if (playerWins+playerLoose%10==0) Console.WriteLine(".");
            }
            catch (OutOfCashException)
            {
                //throw new OutOfCashException();
                //Console.WriteLine("PLayer out of cash");
                Program.playerLoose++;
                //Console.Write(".");
                //if (playerWins + playerLoose % 10 == 0) Console.WriteLine(".");
            }
        }