I've been stuck on this forever, but I think I've realized that my deck builder is ending up making a deck of cards all of the same, last value in the loop.
Here is my code for the deck builder and a hand preparer. It includes an object Card which takes in two integers, here v and s. And an ArrayList of five cards to be dealt. I'd be grateful for some assistance!
public ArrayList buildDeck(){
ArrayList<Card> newDeck = new ArrayList<Card>(52);
for(int v=0;v<13;v++)
for(int s=0;s<4;s++) {
Card nextCard = new Card(v,s);
newDeck.add(nextCard);
}
return newDeck;
}
public ArrayList fiveDeal() {
ArrayList<Card> handOfFive = new ArrayList<Card>(0);
for(int d=0;d<5;d++)
{
handOfFive.add(cardDeck.get((gen.nextInt(cardDeck.size()))));
}
return handOfFive;
}
and here is my Card class
public class Card
{
public static String value;
public static String suit;
public Card()
{
value="100";
suit="Cards";
}
public Card(int v, int s)
{
if(v==0)
value="Jack";
if(v==1)
value="Ace";
if(v==11)
value="Queen";
if(v==12)
value="King";
else
value = String.valueOf(v);
if(s==0)
suit="Clubs";
if(s==1)
suit="Spades";
if(s==2)
suit="Diamonds";
else
suit="Hearts";
}
public static String getCard(Object Card)
{
return value + " of " + suit;
}
}