我无法相信我无法弄清楚这一点。这周末我有一个二十一点的任务。我有一副牌。我已经洗了一副牌。现在我想通过向他开两张牌来开始构建用户手。我想制作一个addCard方法,将卡片放在列表顶部并将其插入手中。我想我知道如何删除它,但我很难得到它。我试过从卡片上获取它,从卡片中获取它只是不喜欢任何东西。它告诉我当前格式中不存在卡片。谢谢!
class BlackJackDeck
{
private const int DECKSIZE = 52;
Random rnd = new Random();
int cardCount = 0;
public List<Card> playerHand;
public List<Card> dealerHand;
public IList<BlackJackCard> Cards { get; private set; }
public BlackJackDeck()
{
NewDeck();
}
private void NewDeck()
{
Cards = new List<BlackJackCard>(DECKSIZE);
for (var i = 0; i < 4; i++)
{
for (var j = 0; j < 13; j++)
{
switch (j)
{
case 8:
case 9:
case 10:
case 11:
Cards.Add(new BlackJackCard { Suit = (Suit)i, Face = (CardFace)j, Value = 10 });
break;
case 12:
Cards.Add(new BlackJackCard { Suit = (Suit)i, Face = (CardFace)j, Value = 11 });
break;
default:
Cards.Add(new BlackJackCard { Suit = (Suit)i, Face = (CardFace)j, Value = (j + 2)});
break;
}
}
}
}
public object shuffleCards()
{
foreach (var Card in Cards)
{
Card.ShuffleRank = rnd.Next(100);
Cards = Cards.OrderBy(x => x.ShuffleRank).ToList();
}
return Cards;
}
BlackJackDeck deck = new BlackJackDeck();
public void needShuffle()
{
if (Cards.Count == 0)
{
deck.shuffleCards();
}
}
}
public void addCard()
{
Card cardToAdd = Cards[0]
}
答案 0 :(得分:0)
更好地询问董事会和纸牌游戏社区。 p>