Skip to content

Instantly share code, notes, and snippets.

@halzate93
Last active March 3, 2017 23:51
Show Gist options
  • Save halzate93/7a9a8989b4553f1bf0be62dda2b24f4c to your computer and use it in GitHub Desktop.
Save halzate93/7a9a8989b4553f1bf0be62dda2b24f4c to your computer and use it in GitHub Desktop.
public class Card
{
public static Card[] BuildDeck ()
{
Suit[] suits = (Suit[])Enum.GetValues (typeof (Suit));
Number[] numbers = (Number[])Enum.GetValues (typeof (Number));
Card[] deck = new Card[suits.Length * numbers.Length];
for (int i=0; i<suits.Length; i++)
for (int j=0; j<numbers.Length; j++)
deck[i*numbers.Length + j] = new Card (suits[i], numbers[j]);
return deck;
}
public Suit Suit
{
get; private set;
}
public Number Number
{
get; private set;
}
public Card (Suit suit, Number number)
{
Suit = suit;
Number = number;
}
}
public enum Suit
{
Heart,
Diamond,
Spade,
Club
}
public enum Number
{
Ace,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Jack,
Queen,
King
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment