Simplify Craps (C#) folder structure

This commit is contained in:
Zev Spitz
2022-01-17 08:24:39 +02:00
parent d4fac2463e
commit 7e480f9461
9 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using System.Diagnostics;
namespace Craps
{
class Program
{
static void Main(string[] args)
{
var ui = new UserInterface();
var game = new CrapsGame(ref ui);
int winnings = 0;
ui.Intro();
do
{
var bet = ui.PlaceBet();
var result = game.Play(out int diceRoll);
switch (result)
{
case Result.naturalWin:
winnings += bet;
break;
case Result.naturalLoss:
case Result.snakeEyesLoss:
case Result.pointLoss:
winnings -= bet;
break;
case Result.pointWin:
winnings += (2 * bet);
break;
// Include a default so that we will be warned if the values of the enum
// ever change and we forget to add code to handle the new value.
default:
Debug.Assert(false); // We should never get here.
break;
}
ui.ShowResult(result, diceRoll, bet);
} while (ui.PlayAgain(winnings));
ui.GoodBye(winnings);
}
}
}