diff --git a/29 Craps/csharp/Craps/.gitignore b/29 Craps/csharp/Craps/.gitignore new file mode 100644 index 00000000..c1cb0dce --- /dev/null +++ b/29 Craps/csharp/Craps/.gitignore @@ -0,0 +1,5 @@ +.vs +TestResults +bin +obj + diff --git a/29 Craps/csharp/Craps/Craps/Program.cs b/29 Craps/csharp/Craps/Craps/Program.cs index d8109a16..916f331a 100644 --- a/29 Craps/csharp/Craps/Craps/Program.cs +++ b/29 Craps/csharp/Craps/Craps/Program.cs @@ -6,8 +6,78 @@ namespace Craps { class Program { + enum Result + { + naturalWin, + snakeEyesLoss, + loss, + pointLoss, + pointWin, + }; + static void Main(string[] args) { + var dice1 = new Dice(); + var dice2 = new Dice(); + var ui = new UserInterface(); + + int winnings = 0; + + ui.Intro(); + + do + { + var bet = ui.PlaceBet(); + var diceRoll = dice1.Roll() + dice2.Roll(); + bool isWinner = false; + + if (Win(diceRoll)) + { + winnings += bet; + isWinner = true; + } + else if (Lose(diceRoll)) + { + winnings -= bet; + isWinner = false; + } + else + { + var point = diceRoll; + ui.Point(point); + + while (true) + { + var newRoll = dice1.Roll() + dice2.Roll(); + if (newRoll == point) + { + winnings += bet; + isWinner = true; + break; + } + else if (newRoll == 7) + { + winnings -= bet; + isWinner = false; + break; + } + + ui.RollAgain(); + } + } + + ui.ShowResult(isWinner, bet); + } while (ui.PlayAgain(winnings)); + } + + private static bool Lose(int diceRoll) + { + throw new NotImplementedException(); + } + + private static bool Win(int diceRoll) + { + throw new NotImplementedException(); } } } diff --git a/29 Craps/csharp/Craps/Craps/UserInterface.cs b/29 Craps/csharp/Craps/Craps/UserInterface.cs new file mode 100644 index 00000000..5b1bb280 --- /dev/null +++ b/29 Craps/csharp/Craps/Craps/UserInterface.cs @@ -0,0 +1,42 @@ +using System; + +namespace Craps +{ + public class UserInterface + { + public UserInterface() + { + } + + public void Intro() + { + } + + public int PlaceBet() + { + return 0; + } + + public bool PlayAgain(int bet) + { + throw new NotImplementedException(); + } + + internal void ShowResult(bool isWinner, int winnings) + { + throw new NotImplementedException(); + } + + internal void RollAgain() + { + throw new NotImplementedException(); + } + + internal void Point(int point) + { + throw new NotImplementedException(); + } + } +} + +