/嗨我想知道我需要做什么才能让这个for循环循环遍历我的枚举,因为它不需要[]。我正在尝试在一副卡片中创建所有卡片。/
using System;
using System.Collections.Generic;
using System.Text;
namespace BlackJackGameX
{
public class Deck
{
Random rNumber = new Random();
List<Card> Cards;
List<Card> ShuffledDeck;
public Deck ()
{
Cards = NewDeck();
}
public void Shuffle()
{
for (int i = 0; i <= 51; ++i)
{
int c = rNumber.Next (1, 53);
ShuffledDeck.Add(Cards[c]);
}
}
/这是主要问题区域,我认为我的构造函数也犯了一个错误,但这可能是一个不相关的问题/
private List<Card> NewDeck(Suit CardSuit, FaceValue CardValue, int iValue)
{
for (int i = 0; i <= 3; i++)
{
for (int j = 0; j <= 12; j++)
{
Card newCard = new Card(CardSuit[i], CardValue[j], iValue[j]);
}
}
}
public void Print()
{
Console.WriteLine(ShuffledDeck[1].CardValue);
Console.ReadLine();
}
}
}
/*This is the other class containing the enums*/
using System;
using System.Collections.Generic;
using System.Text;
namespace BlackJackGameX
{
public enum Suit {Spades, Hearts, Clubs, Diamonds}
public enum FaceValue {Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King}
public class Card
{
public Suit CardSuit;
public FaceValue CardValue;
public int iValue;
public Card (Suit cardSuit, FaceValue cardValue, int ivalue)
{
CardSuit = cardSuit;
CardValue = cardValue;
iValue =ivalue;
}
public Card ()
{
}
}
}