Esempio n. 1
0
        private CardCollection BuildNineThroughAceOfEachSuit()
        {
            var suitFactory     = new SuitFactory();
            var rankFactory     = new RankFactory();
            var nineThroughAces = new List <IRank>
            {
                rankFactory.GetRank(RankEnum.Ace),
                rankFactory.GetRank(RankEnum.King),
                rankFactory.GetRank(RankEnum.Queen),
                rankFactory.GetRank(RankEnum.Jack),
                rankFactory.GetRank(RankEnum.Ten),
                rankFactory.GetRank(RankEnum.Nine),
            };

            var suits = new List <ISuit>
            {
                suitFactory.GetSuit(SuitEnum.Diamonds),
                suitFactory.GetSuit(SuitEnum.Clubs),
                suitFactory.GetSuit(SuitEnum.Hearts),
                suitFactory.GetSuit(SuitEnum.Spades),
            };

            var cardCollection = new CardCollection();

            foreach (var suit in suits)
            {
                foreach (var rank in nineThroughAces)
                {
                    cardCollection.Add(new Card(rank, suit));
                }
            }

            return(cardCollection);
        }
Esempio n. 2
0
 public DeckFactory(SuitFactory suitFactory, RankFactory rankFactory)
 {
     _suitFactory = suitFactory;
     _rankFactory = rankFactory;
 }
        private static ISuit FromFactory(SuitEnum suit)
        {
            var factory = new SuitFactory();

            return(factory.GetSuit(suit));
        }