I have a class to represent a player hand. However I have (in another class) an arraylist where I want to represent a bunch of playerhands. The problem is that I don't know how to add a card to the hand within the arraylist of many hands. I have a class representing both cards and a deck, which works well. I am just trying to understand how to add an object to an object within an arraylist. Thank you!
public class Hand{
ArrayList<Cards> hand;
public Hand(){
hand = new ArrayList<Cards>();}
public Class Pile{
ArrayList<Hand> = pile;
public Pile{
pile = new ArrayList<Hand>();
for(int i=0; i<5; i++){ pile.add(new Hand()); }
}
public void addToPile(int index, int position, Card card){
pile.add(index, pile.get(i).add(Card));
}