I am having a difficulty with a piece of code, it is causing a nullpointerexception and its because my variable is being returned as null, help anyone?
public void newGame()
{
this.theDeck = new Deck();
this.piles = new Pile[Constants.NUM_PILES];
Card tempCard2;
for (int i=Constants.FIRST_LAYOUT_PILE; i <
Constants.NUM_LAYOUT_PILES ; i++)
{
for (int x = 0; x < Constants.initalCardsOnPile(i); x++)
{
tempCard2 = theDeck.dealACard();
this.piles.addACard( tempCard2 );
}
}
}
public void addACard(Card c)
{
cards.addElement(c);
}
public Card dealACard()
{
return cards[curCardIndex++];
}
public void newGame()
{
this.theDeck = new Deck();
this.piles = new Pile[Constants.NUM_PILES];
Card tempCard2;
for (int i=Constants.FIRST_LAYOUT_PILE; i <
Constants.NUM_LAYOUT_PILES ; i++)
{
for (int x = 0; x < Constants.initalCardsOnPile(i); x++)
{
tempCard2 = theDeck.dealACard();
this.piles.addACard( tempCard2 );
}
}
}
public void addACard(Card c)
{
cards.addElement(c);
}
public Card dealACard()
{
return cards[curCardIndex++];
}