我正在创建一副纸牌并将我的套装和值放在枚举中,但我的语法在尝试填充我的列表牌组时是关闭的。另外顺便说一句,Ace 的值可以是 1 或 11,是否有某种方法可以将其合并到我的枚举中,或者我是否需要在执行诸如总结二十一点之类的事情时将其编码?
public class Deck
{
private List<Card> cards;
private Random random = new Random();
public Deck()
{
cards = new List<Card>();
for (int s = 0; s < 4; s++)
//for (int v = 0; v < 14; v++)
foreach(Enum v in Values)
cards.Add(new Card((Suits)s, (Values)v));
}
这是我的适合和价值的枚举:
public enum Suits
{
Spades,
Clubs,
Diamonds,
Hearts
}
public enum Values
{
Ace = 1,
Two = 2,
Three = 3,
Four = 4,
Five = 5,
Six = 6,
Seven = 7,
Eight = 8,
Nine = 9,
Ten = 10,
Jack = 10,
Queen = 10,
King = 10
}