Beispiel #1
0
        public void PlayerHits(Player player)
        {
            Hit(player);

            if (!player.IsBust)
                HitOrStand();
            else
                PlayDealer();
        }
Beispiel #2
0
        public void Init()
        {
            Dealer = new Dealer();
            Player = new Player();

            Player.AddToHand(Dealer.Deal(2));
            Dealer.AddToHand(Dealer.Deal(1));

            WritePlayersState(Player);
            WritePlayersState(Dealer);

            HitOrStand();
        }
Beispiel #3
0
        public void GetScoreReturnsCorrectValue()
        {
            var player = new Player();

            var cards = new Card()
            {
                Suit = CardSuit.Heart,
                Type = CardType.Ace,
                Value = 1
            };

            player.AddToHand(cards);
            Assert.AreEqual(player.GetScore(), 1);
        }
Beispiel #4
0
        public void PlayerIsBust()
        {
            var cards = new List<Card>()
            {
                new Card() { Suit = CardSuit.Diamond, Type = CardType.Queen, Value = 10 },
                new Card() { Suit = CardSuit.Heart, Type = CardType.Number, Value = 7 },
                new Card() { Suit = CardSuit.Spade, Type = CardType.King, Value = 10 }
            };

            var player = new Player();
            player.AddToHand(cards);

            var score = player.GetScore();
            Assert.IsTrue(player.IsBust);
        }
Beispiel #5
0
        public void PlayerIsBustButHasAnAceChangeAceValue()
        {
            var cards = new List<Card>()
            {
                new Card() { Suit = CardSuit.Diamond, Type = CardType.Queen, Value = 10 },
                new Card() { Suit = CardSuit.Heart, Type = CardType.Number, Value = 7 },
                new Card() { Suit = CardSuit.Spade, Type = CardType.Ace, Value = 11 }
            };

            var player = new Player();
            player.AddToHand(cards);

            var score = player.GetScore();

            Assert.IsTrue(score < 21);
            Assert.IsFalse(player.IsBust);
        }
Beispiel #6
0
 public void PlayerStands(Player player)
 {
     Stand(player);
     PlayDealer();
 }
Beispiel #7
0
 public void Hit(Player player)
 {
     player.AddToHand(Dealer.Deal(1));
     WritePlayersState(player);
 }
Beispiel #8
0
 private void WriteWins(Player player)
 {
     WriteLine(String.Format("{0} wins!", player.ToString()));
 }
Beispiel #9
0
 private void WriteScoreToConsole(Player player, int score)
 {
     WriteLine(String.Format("{0}s score is: {1}", player.ToString(), score));
     LineBreak();
 }
Beispiel #10
0
        private void WritePlayersState(Player player)
        {
            WritePlayerHasMessageToConsole(player);
            WriteHandToConsole(player.GetHand());
            WriteScoreToConsole(player, player.GetScore());

            if (player.IsBust)
            {
                WriteIsBust(player);
            }
        }
Beispiel #11
0
 private void WritePlayerHasMessageToConsole(Player player)
 {
     LineBreak();
     WriteLine(String.Format("{0} has: ", player.ToString()));
 }
Beispiel #12
0
 public void WriteIsBust(Player player)
 {
     WriteLine(String.Format("{0} is Bust!", player.ToString()));
 }
Beispiel #13
0
 public void Stand(Player player)
 {
     player.Stand = true;
     WriteLine(player.ToString() + " has finished with " + player.GetScore());
 }
Beispiel #14
0
 public void ToStringReturnsPlayerName()
 {
     var player = new Player();
     Assert.AreEqual(player.ToString(), player.Name);
 }