I should be able to figure this out, but I'm completely lost.
The following code deals a hand of a set number of cards:
private void deal(Hand hand, int toDeal)
{
for (int j = 0; j < toDeal; j++)
{
Hand temp = hand.handCards();
Card[] s = new Card[temp.getNumCards() + 1];
Card[] q = hand.getHand();
for (int k = 0; k < temp.getNumCards(); k++)
{
s[k] = q[k];
}
s[s.length - 1] = deck.dealCard(); // ***THE METHOD SHOWN BELOW***
hand.setHand(s);
}
}
deck.dealCard():
public Card dealCard()
{
Card toDeal = cards.get(numCards());
cards.remove(numCards());
return toDeal;
}
to call it I run:
deal(playerHand, 5);
How do I make a method to add these cards back into the deck (the cards from the temp array)?
Thank you,
any ideas or code greatly appreciated