Last active
March 3, 2017 23:51
-
-
Save halzate93/7a9a8989b4553f1bf0be62dda2b24f4c to your computer and use it in GitHub Desktop.
This file contains 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
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