示例#1
0
 public Shuffler(PackOfCards pack)
 {
     _pack           = pack;
     _cardsRemaining = new List <int>();
     initCardNumbers();
     _random = new Random();
 }
示例#2
0
        private static void cardstuff()
        {
            // Initialise cards
            var pack = new PackOfCards();

            // Each player gets 13 cards
            var player1Hand = new Card[13];
            var player2Hand = new Card[13];
            var player3Hand = new Card[13];
            var player4Hand = new Card[13];
            var playerNo    = 1;
            var cardno      = 0;

            foreach (Card card in pack.Shuffle())
            {
                switch (playerNo)
                {
                case 1:
                    player1Hand[cardno] = card;
                    break;

                case 2:
                    player2Hand[cardno] = card;
                    break;

                case 3:
                    player3Hand[cardno] = card;
                    break;

                default:
                    player4Hand[cardno] = card;
                    break;
                }

                playerNo = playerNo + 1;

                if (playerNo > 4)
                {
                    cardno++;
                    playerNo = 1;
                }
            }

            Console.WriteLine("Player One's Hand:");

            for (int i = 0; i < 13; i++)
            {
                Console.WriteLine(player1Hand[i].ToString());
            }
        }