You haven't actually initialized any PlacePiece
variable and your method isn't static, so how do you want to call it? Also in your placePiece
function you should pass char[][] gBoard
, that you aren't passing.
My guess is that you are trying to make a game and don't know how, sou you just copied some function from internet without knowing the function.
So, in your Board
class I bet that you have something like this:
public class Board {
private char[][] board; // you should initialize it in constructor
public char[][] getBoard() {
return board;
}
}
Then you should create your placePiece
variable in Game
class and use it:
public class Game {
private Board gBoard;
private PlacePiece placePiece;
public Game() {
gBoard = new Board();
placePiece = new PlacePiece();
placePiece.placePiece(gBoard.getBoard()); // you have to pass variable to placePiece() function
}
}
I don't think you know, what you're doing otherwise you wouldn't have made these mistakes, so I highly recommend you taking some Java tutorial, so you have some foundation and then start doing more complex tasks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…