コード例 #1
0
        public IPackOfCards Create()
        {
            PackOfCards newPack = new PackOfCards();
            Card newCard;

            // Clubs
            for (int i = 1; i <= 13; i++)
            {
                newCard = new Card(i, Suit.Clubs);
                newPack.AddCard(newCard);
            }

            // Diamonds
            for (int i = 1; i <= 13; i++)
            {
                newCard = new Card(i, Suit.Diamonds);
                newPack.AddCard(newCard);
            }

            // Hearts
            for (int i = 1; i <= 13; i++)
            {
                newCard = new Card(i, Suit.Hearts);
                newPack.AddCard(newCard);
            }

            // Spades
            for (int i = 1; i <= 13; i++)
            {
                newCard = new Card(i, Suit.Spades);
                newPack.AddCard(newCard);
            }

            return newPack;
        }
コード例 #2
0
        public IPackOfCards Create()
        {
            PackOfCards newPack = new PackOfCards();
            Card        newCard;

            // Clubs
            for (int i = 1; i <= 13; i++)
            {
                newCard = new Card(i, Suit.Clubs);
                newPack.AddCard(newCard);
            }

            // Diamonds
            for (int i = 1; i <= 13; i++)
            {
                newCard = new Card(i, Suit.Diamonds);
                newPack.AddCard(newCard);
            }

            // Hearts
            for (int i = 1; i <= 13; i++)
            {
                newCard = new Card(i, Suit.Hearts);
                newPack.AddCard(newCard);
            }

            // Spades
            for (int i = 1; i <= 13; i++)
            {
                newCard = new Card(i, Suit.Spades);
                newPack.AddCard(newCard);
            }

            return(newPack);
        }
コード例 #3
0
        public IPackOfCards Create()
        {
            var pack = new PackOfCards();

            foreach (Rank rank in Enum.GetValues(typeof(Rank)))
            {
                foreach (SuitType suit in Enum.GetValues(typeof(SuitType)))
                {
                    var card = new Card(suit, rank);
                    pack.Add(card);
                }
            }

            return(pack);
        }
コード例 #4
0
        public IPackOfCards Create()
        {
            var values =
                Enumerable.Range(2, 9).Select(x => x.ToString()).Concat(new[] { "Ace", "Jack", "Queen", "King" }).ToList();

            var deck = new List <ICard>();

            foreach (var suit in Enum.GetValues(typeof(CardSuit)))
            {
                deck.AddRange(from value in values select new Card((CardSuit)suit, value));
            }

            var pack = new PackOfCards(deck);

            return(pack);
        }
コード例 #5
0
        public IPackOfCards Create()
        {
            IPackOfCards packOfCards = new PackOfCards();

            return(packOfCards);
        }