static void Main(string[] args) { BlackJackGame game = new BlackJackGame(); game.Play(); }
static void Main(string[] args) { const string casinoName = "Grand Hotel and Casino"; Console.WriteLine("Welcome to the {0}. Let's start by telling me your name.", casinoName); string playerName = Console.ReadLine(); if (playerName.ToLower() == "admin") { List <ExceptionEntity> Exceptions = ReadExceptions(); foreach (var exception in Exceptions) { Console.WriteLine(exception.ID + " | "); Console.WriteLine(exception.ExceptionType + " | "); Console.WriteLine(exception.ExceptionMessage + " | "); Console.WriteLine(exception.TimeStamp + " | "); Console.WriteLine(); } Console.Read(); return; } bool validAnswer = false; int bank = 0; while (!validAnswer) { Console.WriteLine("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 Black Jack right now?", playerName); string answer = Console.ReadLine().ToLower(); if (answer == "yes" || answer == "yeah" || answer == "yaas") { Player player = new Player(playerName, bank); player.Id = Guid.NewGuid(); using (StreamWriter file = new StreamWriter(@"C:\Users\Student\Desktop\Basic_CS_Projects\Basic-C-Sharp-Projects\BlackJack\log.txt", true)) { file.WriteLine(player.Id); } Game game = new BlackJackGame(); game += player; player.isActivelyPlaying = true; while (player.isActivelyPlaying && player.Balance > 0) { try { game.Play(); } catch (FraudException ex) { Console.WriteLine(ex.Message); UpdateDBWithException(ex); Console.Read(); return; } catch (Exception ex) { Console.WriteLine("An error occurred. Please contact your system administrator"); UpdateDBWithException(ex); Console.Read(); return; } } 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) { string playerName; do { Console.WriteLine("Welcome to the Grand Hotel and Casino. Let's star be telling me your name."); 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 + " | \n"); } Console.Read(); return; } }while (string.IsNullOrEmpty(playerName)); //converted to a check to see if a number entered Console.WriteLine("How much money did you bring today?"); int bank; bool corInt = int.TryParse(Console.ReadLine(), out bank) && bank > 0; while (!corInt) { Console.WriteLine("You didn't enter a correct amount, please try again."); corInt = int.TryParse(Console.ReadLine(), out bank) && bank > 0; if (!corInt) { Console.WriteLine("Please enter number digits only."); } } Console.WriteLine("Hello, {0}. Would you like to joing a game of Blackjack right now?", playerName); string answer = Console.ReadLine().ToLower(); if (answer == "yes" || answer == "yeah" || answer == "ya" || answer == "y") { Player player = new Player(playerName, bank); player.Id = Guid.NewGuid(); using (StreamWriter file = new StreamWriter(@"C:\Users\coach\Documents\The-Tech-Academy-Projects\C-Sharp\log.txt", true)) { file.WriteLine(player.Id); } Game game = new BlackJackGame(); 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.ReadLine(); }