Console struct card
<p>I have a C# project to create a console project named Cards that includes a struct <code>Card</code>, two classes <code>Deck</code> and <code>Hand</code>, and two enums: <code>Rank</code> and <code>Suit</code>. Set the values of the enumerators in <code>Suit</code> to the integer values corresponding to the characters ♠, ♣, ♦, and ♥, and use these symbols to represent the suit when override the <code>ToString</code> method of <code>Card</code>.</p>

<p>Output: </p>

<p>![The project Output]</p>

<p>New Deck: </p>

<pre>
♠ Ace ♣ Ace ♥ Ace ♦ Ace 
♠ Deuce ♣ Deuce ♥ Deuce ♦ Deuce
♠ Three ♣ Three ♥ Three ♦ Three 
♠ Four ♣ Four ♥ Four ♦ Four 
♠ Five ♣ Five ♥ Five ♦ Five 
♠ Six ♣ Six ♥ Six ♦ Six 
♠ Seven ♣ Seven ♥ Seven ♦ Seven 
♠ Eight ♣ Eight ♥ Eight ♦ Eight 
♠ Nine ♣ Nine ♥ Nine ♦ Nine 
♠ Ten ♣ Ten ♥ Ten ♦ Ten 
♠ Jack ♣ Jack ♥ Jack ♦ Jack 
♠ Queen ♣ Queen ♥ Queen ♦ Queen 
♠ King ♣ King ♥ King ♦ King 
</pre>

<p>Shuffeled Deck:</p>

<pre>
♣ Ten ♠ Three ♠ Six ♣ Queen 
♠ Four ♥ Nine ♥ Deuce ♠ Seven 
♦ Six ♣ Nine ♥ Ten ♥ King 
♣ Ace ♣ Five ♦ King ♠ King 
♦ Ace ♠ Jack ♦ Jack ♠ Eight 
♣ Three ♦ Eight ♥ Six ♣ Jack 
♠ Ace ♠ Five ♥ Jack ♥ Ace 
♦ Four ♥ Four ♥ Three ♥ Queen 
♦ Nine ♣ Eight ♣ Six ♠ Ten 
♦ Ten ♦ Five ♥ Seven ♣ Four 
♦ Deuce ♦ Three ♥ Eight ♦ Seven 
♠ Nine ♣ King ♦ Queen ♥ Five 
♣ Seven ♠ Deuce ♠ Queen ♣ Deuce 
</pre>

<p>Dealing hands of 5 cards:</p>

<pre>
♠ Five ♠ Six ♠ Seven ♠ Eight ♠ Nine     Straight Flush 
♣ Four ♣ Six ♣ Seven ♣ Eight ♣ Queen    Flush 
♦ Six ♦ Seven ♥ Eight ♥ Nine ♣ Ten      Straight 
♣ Deuce ♣ Six ♣ Nine ♦ Ten ♣ Queen 
♣ Eight ♠ Ten ♥ Jack ♠ Queen ♦ King 
</pre>

<p>I have all my class but when I compile it only show this !</p>

<p>Here's the command prompt of my output </p>

<p><img src="http://i.stack.imgur.com/ac6Sf.jpg" alt="Output"></p>

<p>Here is my code I have create.</p>

<p>Program.cs</p>

<pre><code>namespace Cards {

    class Program
    {
        static void Main(string[] args)
        {

            Deck deck = new Deck();
            deck.Shuffle();

            for (int i = 0; i &lt; 5; i++)
            {
                Hand hand1 = new Hand(deck.Deal(5));
                Console.WriteLine(hand1.ToString());
            }

            Console.ReadKey();
        }
    }
}
</code></pre>

<p>Hand.cs</p>

<pre><code>namespace Cards
{
    class Hand
    {
        public List&lt;Card&gt; Cards
        {
            get;
            private set;
        }

        public Hand(List&lt;Card&gt; newHand)
        {
            newHand.Sort();
            this.Cards = newHand;
        }

        public bool IsFlush()
        {

            int spadeCount = 0;
            int heartCount = 0;
            int clubCount = 0;
            int diamondCount = 0;

            foreach (Card c in Cards)
            {
                switch (c.CardSuit)
                {
                    case Suit.SPADE:
                        spadeCount++;
                        break;
                    case Suit.HEART:
                        heartCount++;
                        break;
                    case Suit.CLUB:
                        clubCount++;
                        break;
                    case Suit.DIAMOND:
                        diamondCount++;
                        break;
                }
            }

            bool isFlush = spadeCount &gt;= 5 || heartCount &gt;= 5 || clubCount &gt;= 5 || diamondCount &gt;= 5;

            return isFlush;
        }

        public bool IsStraight()
        {
            int straightCount = 0;

            object lastCard = null;

            foreach (Card c in Cards)
            {
                if (lastCard == null)
                {
                    lastCard = c;
                }

                if (c.CardRank - ((Card)lastCard).CardRank == 1)
                {
                    straightCount++;
                }

                lastCard = c;
            }

            bool isStraight = straightCount &gt;= 5;
            return isStraight;
        }


        public override String ToString()
        {
            String output = "";

            foreach (Card c in Cards)
            {
                output += String.Format("{0}", c.ToString());
            }


            if (IsFlush() &amp;&amp; IsStraight())
            {
                output += " Straight Flush";
            }
            else if (IsFlush())
            {
                output += " Flush";
            }
            else if (IsStraight())
            {
                output += " Straight";
            }

            return output;
        }
    }
}
</code></pre>

<p>Deck.cs</p>

<pre><code>namespace Cards
{
    class Deck
    {
        public List&lt;Card&gt; Cards
        {
            get;
            private set;
        }

        public Deck()
        {
            this.Cards = Deck.NewDeck();
        }

        public Deck(List&lt;Card&gt; cardDeck)
        {
            this.Cards = cardDeck;
        }

        public void Shuffle()
        {
            Random random = new Random();
            for (int i = this.Cards.Count; i &gt; 1; i--)
            {
                int j = random.Next(i);

                Card tmp = this.Cards[j];
                this.Cards[j] = this.Cards[i - 1];
                this.Cards[i - 1] = tmp;
            }
        }

        public List&lt;Card&gt; Deal(int i)
        {
            if (i &gt; this.Cards.Count)
            {
                return new List&lt;Card&gt;();
            }

            List&lt;Card&gt; dealtCards = new List&lt;Card&gt;();
            for (int j = 0; j &lt; i; j++)
            {
                dealtCards.Add(this.Cards[j]);
            }

            this.Cards.RemoveRange(0, i);

            return dealtCards;
        }

        public override string ToString()
        {
            String output = "";
            int suitCount = 4;
            int currCount = 0;

            List&lt;Card&gt; sortedDeck = NewDeck();

            foreach (Card c in sortedDeck)
            {
                output += String.Format("{0,-9}", c.ToString());
                if (++currCount == suitCount)
                {
                    output += "\n";
                    currCount = 0;
                }
            }

            return output;
        }

        public static List&lt;Card&gt; NewDeck()
        {
            List&lt;Card&gt; newDeck = new List&lt;Card&gt;();

            foreach (Cards.Rank rank in Enum.GetValues(typeof(Cards.Rank)))
            {
                foreach (Cards.Suit suit in Enum.GetValues(typeof(Cards.Suit)))
                {
                    newDeck.Add(new Card(suit, rank));
                }
            }

            return newDeck;
        }
    }
}
</code></pre>

<p>Card.cs</p>

<pre><code>namespace Cards
{
    public enum Suit { DIAMOND, CLUB, HEART, SPADE };
    public enum Rank { ACE, DEUCE, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING };

    public struct Card : IComparable&lt;Card&gt;
    {

        public Suit CardSuit
        {
            get;
            private set;
        }

        public Rank CardRank
        {
            get;
            private set;
        }

        public Card(Suit _suit, Rank _rank)
            : this()
        {
            this.CardSuit = _suit;
            this.CardRank = _rank;
        }

        public override string ToString()
        {
            String rank = "";
            String suit = "";

            switch (this.CardRank)
            {
                case Rank.ACE:
                    rank = "Ace";
                    break;
                case Rank.DEUCE:
                    rank = "Deuce";
                    break;
                case Rank.THREE:
                    rank = "Three";
                    break;
                case Rank.FOUR:
                    rank = "Four";
                    break;
                case Rank.FIVE:
                    rank = "Five";
                    break;
                case Rank.SIX:
                    rank = "Six";
                    break;
                case Rank.SEVEN:
                    rank = "Seven";
                    break;
                case Rank.EIGHT:
                    rank = "Eight";
                    break;
                case Rank.NINE:
                    rank = "Nine";
                    break;
                case Rank.TEN:
                    rank = "Ten";
                    break;
                case Rank.JACK:
                    rank = "Jack";
                    break;
                case Rank.QUEEN:
                    rank = "Queen";
                    break;
                case Rank.KING:
                    rank = "King";
                    break;
            }

            switch (this.CardSuit)
            {
                case Suit.SPADE:
                    suit = (char)6 + "";
                    break;
                case Suit.HEART:
                    suit = (char)3 + "";
                    break;
                case Suit.DIAMOND:
                    suit = (char)4 + "";
                    break;
                case Suit.CLUB:
                    suit = (char)5 + "";
                    break;
            }

            return String.Format("{0} {1}", suit, rank);
        }

        public int CompareTo(Card other)
        {
            int compare = this.CardRank.CompareTo(other.CardRank);

            if (compare.Equals(0))
            {
                return this.CardSuit.CompareTo(other.CardSuit);
            }

            return compare;
        }
    }
}
</code></pre>
