I have a small struct -
struct Card {
public string suit;
public string value;
}
Which I then use to initialize an array of cards
Card[] deck = new Card[52];
In my Main(), I call
Deck myDeck = new Deck();
Which correlates to the constructor
public Deck() {
int cardNum = 0;
for (int i = 0; i < numSuits; i++) {
for (int a = 0; a < numValues; a++) {
deck[cardNum].suit = suits[i];
deck[cardNum].value = values[a];
Console.WriteLine("The card at position " + (cardNum + 1) + " is the " + deck[cardNum].value + " of " + deck[cardNum].suit);
cardNum++;
}
}
}
... thus creating a deck with 52 cards, which as confirmed by my Console.WriteLine(), populates the deck correctly.
My issue is I have 2 other methods, public void Shuffle() and public string Deal() which, as their names suggest, shuffle the deck and deal the top card respectively, however I do not know how to pass the deck.suit and deck.value values into said methods.
I have tried initializing the Card[] array inside the constructor. All of these functions are under the same namespace and class.
I would also like to keep the constructor and two methods in the code and not use anything else, even though I'm sure there are many other, potentially easier ways to do this.
Thanks in advance!