public boolean upgrade(int role, int x, int y, int target_x, int target_y) { switch (role){ case 1: theChessBoard.initialize(target_x, target_y, new Knight(theChessBoard.getPiece(x, y).getColor(),"1")); return true; case 2: theChessBoard.initialize(target_x, target_y, new Bishop(theChessBoard.getPiece(x, y).getColor(),"1")); return true; case 3: theChessBoard.initialize(target_x, target_y, new Rook(theChessBoard.getPiece(x, y).getColor(),"1")); return true; case 4: theChessBoard.initialize(target_x, target_y, new Queen(theChessBoard.getPiece(x, y).getColor(),"1")); return true; default: return false; } } This step is behind the move action, so theChessBoard.getPiece(x, y) should be theChessBoard.getPiece(target_x, target_y)