예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Grand Hotel and Casino. Start 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("Whats up, {0}. would you like to join a game of blackjack?", playerName);
            string answer = Console.ReadLine().ToLower();

            if (answer == "yes") //|| answer == "yeah" || answer == "y" || answer == "ya" || answer = "ok") this code is not working the OR operator
            {
                Player player = new Player(playerName, bank);
                Game   game   = new blackJackGame();
                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 bye now!");
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            const string casinoName = "Grand Hotel and Casiono";



            Console.WriteLine("Welcome to the Grand Hotel and Casino. 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.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("Whats up, {0}. would you like to join a game of blackjack?", playerName);
            string answer = Console.ReadLine().ToLower();

            if (answer == "yes") //|| answer == "yeah" || answer == "y" || answer == "ya" || answer = "ok") this code is not working the OR operator
            {
                Player player = new Player(playerName, bank);
                player.Id = Guid.NewGuid();
                using (StreamWriter file = new StreamWriter(@"C:\Users\18015\Documents\yeah.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 has occured, please contact your system Admin");
                        UpdateDbWIthException(ex);
                        Console.ReadLine();
                        return;
                    }
                }
                game -= player;
                Console.WriteLine("Thank you for playing!");
            }
            Console.WriteLine("Feel free to look around the Casino. bye bye now!");
            Console.ReadLine();
        }