public void BlackjackTopCardIsAlwaysEleven() { Blackjack blackie = new Blackjack(); for(int i=0;i<52;i++) { int value = blackie.PlayFirstHand().Value; Assert.IsTrue(value <= 11); } }
static void Main(string[] args) { Console.WriteLine("What is your name?"); string playerName = Console.ReadLine(); Thread.Sleep(1000); Console.WriteLine("Welcome {0},", playerName); Console.WriteLine("I want to play a game"); Thread.Sleep(1500); Console.WriteLine("A game of blackjack"); Console.WriteLine("You will play against the computer, and the goal of the game is to achieve the score closest to 24 without going over it"); Thread.Sleep(3000); Console.WriteLine("Do you wish to play? (y/n)"); string answer = Console.ReadLine(); Thread.Sleep(1500); if (answer == "y") { _blackjack = new Blackjack(); do { _blackjack.GiveUserCard(); PrintCards(); if (_blackjack.CanContinue()) { Console.WriteLine("Do you wish to draw more cards? (y/n)"); answer = Console.ReadLine(); } else { answer = "n"; _blackjack.scoreCalculator(-1, 0); } } while (answer == "y"); do { _blackjack.GiveComCard(); PrintComCards(); Thread.Sleep(1000); if (_blackjack.ComCanContinue()) { answer = "y"; } else { answer = "n"; _blackjack.scoreCalculator(0, -1); } } while (answer == "y"); int winner = _blackjack.scoreCalculator(_blackjack.UserScore, _blackjack.ComScore); if (winner == 1) { Console.WriteLine("Congratulations {0}", playerName); Thread.Sleep(500); Console.WriteLine("You win this time"); Thread.Sleep(1500); Console.WriteLine("** Press enter to close the window **"); Console.ReadLine(); } if (winner == 2) { Console.WriteLine("You lose,"); Thread.Sleep(500); Console.WriteLine("Better luck next time.."); Thread.Sleep(1500); Console.WriteLine("** Press enter to close the window **"); Console.ReadLine(); } if (winner == 3) { Console.WriteLine("It is a tie"); Thread.Sleep(500); Console.WriteLine("Looks like you two are at the same power level"); Thread.Sleep(1500); Console.WriteLine("** Press enter to close the window **"); Console.ReadLine(); } //******************************************************************************************************* } else if (answer == "n") { Console.WriteLine("Very well.."); Thread.Sleep(1000); Console.WriteLine("** Press enter to close the window **"); Console.ReadLine(); } else { Console.WriteLine("I will take that as a no.."); Thread.Sleep(1000); Console.WriteLine("** Press enter to close the window **"); Console.ReadLine(); } }