示例#1
0
        public CardSet()
        {
            cardArray = new SuperCard[52];
            int count = 0;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 2; j < 15; j++)
                {
                    switch (i)
                    {
                    case 0:
                        cardArray[count] = new CardClub((Rank)j);
                        break;

                    case 1:
                        cardArray[count] = new CardDiamond((Rank)j);
                        break;

                    case 2:
                        cardArray[count] = new CardHeart((Rank)j);
                        break;

                    case 3:
                        cardArray[count] = new CardSpade((Rank)j);
                        break;
                    }
                    count++;
                }
            }
        }
示例#2
0
        // Return a new child card class based on the enum passed in.
        public SuperCard MakeCard(Suit suit, Rank rank)
        {
            // Parent class needs to hold the child class
            SuperCard card = null;

            // "Cast" Suit enum to proper SuperCard child class
            switch (suit)
            {
            case Suit.Club:
                card = new CardClub(rank);
                break;

            case Suit.Diamond:
                card = new CardDiamond(rank);
                break;

            case Suit.Heart:
                card = new CardHeart(rank);
                break;

            case Suit.Spade:
                card = new CardSpade(rank);
                break;
            }

            // Return the new card
            return(card);
        }
示例#3
0
        public CardSet()
        {
            CardArray = new SuperCard[52];

            int index = 0;

            for (int i = 0; i <= 4; i++)
            {
                for (int j = 2; j <= 14; j++)
                {
                    switch (i)
                    {
                    case 0:
                        CardArray[index] = new CardClub((Rank)(j));
                        break;

                    case 1:
                        CardArray[index] = new CardDiamond((Rank)(j));
                        break;

                    case 2:
                        CardArray[index] = new CardHeart((Rank)(j));
                        break;

                    case 3:
                        CardArray[index] = new CardSpade((Rank)(j));
                        break;
                    }
                    index++;
                }
            }
        }
示例#4
0
        public CardSet()
        {
            cardArray = new SuperCard[52];



            int i = 0;

            while (i <= 51)
            {
                for (int a = 2; a <= 14; a++)
                {
                    cardArray[i] = new CardClub((Rank)(a));
                    i++;
                }
                for (int b = 2; b <= 14; b++)
                {
                    cardArray[i] = new CardHeart((Rank)(b));
                    i++;
                }
                for (int c = 2; c <= 14; c++)
                {
                    cardArray[i] = new CardSpade((Rank)(c));
                    i++;
                }
                for (int d = 2; d <= 14; d++)
                {
                    cardArray[i] = new CardDiamond((Rank)(d));
                    i++;
                }
            }
        }
示例#5
0
        public CardSet()  // this is our constuctor, whose job it is to create all the 52 cards.
        {
            cardArray = new SuperCard[NUM_OF_CARDS];

            int i = 0;

            foreach (Suit s in Enum.GetValues(typeof(Suit)))
            {
                switch (s)
                {
                case Suit.Club:
                    foreach (Rank v in Enum.GetValues(typeof(Rank)))
                    {
                        cardArray[i] = new CardClub(v);
                        i++;
                    }
                    break;

                case Suit.Diamond:
                    foreach (Rank v in Enum.GetValues(typeof(Rank)))
                    {
                        cardArray[i] = new CardDiamond(v);
                        i++;
                    }
                    break;

                case Suit.Heart:
                    foreach (Rank v in Enum.GetValues(typeof(Rank)))
                    {
                        cardArray[i] = new CardHeart(v);
                        i++;
                    }
                    break;

                case Suit.Spade:
                    foreach (Rank v in Enum.GetValues(typeof(Rank)))
                    {
                        cardArray[i] = new CardSpade(v);
                        i++;
                    }
                    break;
                }
            }
        }
示例#6
0
        //constructor
        public CardSet()
        {
            cardArray = new SuperCard[52];



            //looping for CardClub
            int index2 = 2;

            for (int index1 = 0; index1 < 13; index1++)
            {
                cardArray[index1] = new CardClub((Rank)(index2));
                index2            = index2 + 1;
            }

            //looping for cardDiamond
            index2 = 2;
            for (int index1 = 13; index1 < 26; index1++)
            {
                cardArray[index1] = new CardDiamond((Rank)(index2));
                index2            = index2 + 1;
            }

            //looping for cardHeart
            index2 = 2;
            for (int index1 = 26; index1 < 39; index1++)
            {
                cardArray[index1] = new CardHeart((Rank)(index2));
                index2            = index2 + 1;
            }
            //looping for cardSpade
            index2 = 2;
            for (int index1 = 39; index1 < 52; index1++)
            {
                cardArray[index1] = new CardSpade((Rank)(index2));
                index2            = index2 + 1;
            }
        }//end of constructor