So I have a constructor and a method that returns a card. I'm getting an InvalidOperationException for some reason. Anyone can think of anything?
The cards list is not empty, I just removed the card generation algorithm from the constructor here to make it easier to read.
Here's the code:
public Deck()
{
cards = new List<Card>();
cardStack = new Stack<Card>();
// cards list gets populated here
foreach (Card card in cards)
{
cardStack.Push(card);
}
}
public Card drawCard()
{
return cardStack.Pop(); // This line is giving me an InvalidOperationException
}
Thanks!