Created
October 20, 2014 05:41
-
-
Save lamchau/0d41bdeba51a229afc5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace ConsoleApplication | |
| { | |
| enum Suit | |
| { | |
| DIAMOND, | |
| CLUB, | |
| HEART, | |
| SPADE | |
| }; | |
| enum Rank | |
| { | |
| ACE = 1, | |
| TWO = 2, | |
| THREE = 3, | |
| FOUR = 4, | |
| FIVE = 5, | |
| SIX = 6, | |
| SEVEN = 7, | |
| EIGHT = 8, | |
| NINE = 9, | |
| TEN = 10, | |
| JACK = 11, | |
| QUEEN = 12, | |
| KING = 13 | |
| }; | |
| class Card | |
| { | |
| public Suit suit { get; set; } | |
| public Rank rank { get; set; } | |
| } | |
| public class Program | |
| { | |
| public static void Main() | |
| { | |
| var suits = Enum.GetValues(typeof(Suit)); | |
| var ranks = Enum.GetValues(typeof(Rank)); | |
| Card[] cards = new Card[52]; | |
| int index = 0; | |
| foreach (Suit s in suits) | |
| { | |
| foreach (Rank r in ranks) | |
| { | |
| Card card = new Card(); | |
| card.suit = s; | |
| card.rank = r; | |
| cards[index++] = card; | |
| } | |
| } | |
| foreach (Card c in cards) | |
| { | |
| Console.WriteLine("{0}: {1}", c.rank, c.suit); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment