i'm using Piles. Piles in my case, are objects containing Card ArrayLists. I'm going to be using more than 1 of them, each different to their purpose.
What i'm trying to do here is make 2 methods:
getCards: that moves Object refernces from one Pile to another
removeCards: that deletes a number of arraylist entries
import java.util.ArrayList;
public abstract class Pile {
public static ArrayList <Card> newPile;
public Pile() {
newPile = new ArrayList <Card>();
}
public abstract void displayPile();
public void removeCards(int numOfCards) {
for (int i = 0; i < numOfCards; i++) {
Pile.newPile.remove(0);
}
}
public static void getCards(int numOfCards, Pile fromPile) {
for (int i = 0; i < numOfCards; i++) {
Pile.newPile.add(i, fromPile.newPile.get(i)); // here is the error
}
}
}
The error is:
The static field Pile.newPile should be accessed in a static way.
Anyone cares to explain what i'm doing wrong and how can i deal with it?