Ejemplo n.º 1
0
        private static void PrintHand(Player player, Hand hand)
        {
            string handName = null;

            if (player is HumanPlayer)
            {
                HumanPlayer humanPlayer = (HumanPlayer)player;

                if (hand.IsSplit)
                {
                    handName = "other hand";
                }
                else
                {
                    handName = "hand";
                }
            }
            else
            {
                handName = "hand";
            }

            string             result = $"{player.Name}'s " + handName + " is: ";
            IEnumerable <Card> cards  = hand.GetCards();

            if (cards.Count() == 0)
            {
                result += "empty";
            }
            else
            {
                List <string> cardStrings = new List <string>();
                foreach (Card card in cards)
                {
                    cardStrings.Add(GetCardString(card));
                }
                result += string.Join(", ", cardStrings);
            }
            Console.WriteLine(result);
        }