I want to store the player's data and the field's data in two arrays of object. The problem is I need to work with these in a different classes. In the class where I originally created its not a problem but when I try to call it in another class it throws "board[i]
cannot be resolved to a variable".
The code I am writing is kind of similar to this:
class Field {
int something;
int another;
public void setMethod(int something){
this.something = something;
}
//etc.
}
class Board {
public static Field[] board = new Field[60];
public void BoardFiller(){
for(int i = 0; i < board.length; i++){
board[i] = new Field(/*construct*/);
//etc.
}
}
}
class Gameplay {
public boolean Attackable() {
boolean atk = false;
//stuff
int something = board[i].getMethod();
//more stuff
return atk;
}
}
And so on. I have to use the Field data to check if it's reachable, use it in the turns, in the I/O part. The problem is the same with the Player data.
Board.board[i]
– Mark B Apr 16 '16 at 16:34