static void Main(string[] args) { Console.WriteLine("Welcome to the Grand Hotel and Casino. Let's startd by telling me your name."); string playerName = Console.ReadLine(); Console.WriteLine("And how much money did you bring today?"); int bank = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Hello, {0}. Would you like to join a game of 21 right now?", playerName); string answer = Console.ReadLine().ToLower(); if (answer == "yes" || answer == "yeah" || answer == "y" || answer == "ya") { Player player = new Player(playerName, bank); Game game = new TwentyOneGame(); game += player; player.isActivelyPlaying = true; while (player.isActivelyPlaying && player.Balance > 0) { game.Play(); } game -= player; Console.WriteLine("Thank you for playing!"); } Console.WriteLine("Feel free to look around the casino. Bye for now."); Console.Read(); }
static void Main(string[] args) { const string casinoName = "Grand Hotel and Casino"; Console.WriteLine("Welcome to the Grand Hotel and Casino. Let's start by telling me your name."); string playerName = Console.ReadLine(); if (playerName.ToLower() == "admin") { List <ExceptionEntity> Exceptions = ReadExceptions(); foreach (var exception in Exceptions) { Console.Write(exception.Id + " | "); Console.Write(exception.ExceptionType + " | "); Console.Write(exception.ExceptionMessage + " | "); Console.Write(exception.TimeStamp + " | "); Console.WriteLine(); } Console.Read(); return; } bool validAnswer = false; int bank = 0; while (!validAnswer) { Console.WriteLine("And how much money did you bring today?"); validAnswer = int.TryParse(Console.ReadLine(), out bank); if (!validAnswer) { Console.WriteLine("Please enter digits only, no decimals."); } } Console.WriteLine("Hello, {0}. Would you like to join a game of 21 right now?", playerName); string answer = Console.ReadLine().ToLower(); if (answer == "yes" || answer == "yeah" || answer == "y" || answer == "ya") { Player player = new Player(playerName, bank); player.Id = Guid.NewGuid(); using (StreamWriter file = new StreamWriter(@"C:\Test\log.txt", true)) { file.WriteLine(player.Id); } Game game = new TwentyOneGame(); game += player; player.isActivelyPlaying = true; while (player.isActivelyPlaying && player.Balance > 0) { try { game.Play(); } catch (FraudException ex) { Console.WriteLine(ex.Message); UpdateDbWithException(ex); Console.ReadLine(); return; } catch (Exception ex) { Console.WriteLine("An error occurred. Please contact your System Administrator."); UpdateDbWithException(ex); Console.ReadLine(); return; } } game -= player; Console.WriteLine("Thank you for playing!"); } Console.WriteLine("Feel free to look around the casino. Bye for now."); Console.Read(); }