the class is the same.
but there are two methods:
first method:
if simply returns a string.
public String FindPiece(String chessPiece) {
return name;
}
name. is a constructor variable. it is a name of the chess piece
public Pawn(String name){
this.name=name;
}
second method
public boolean isMoveValid(ChessPiece[][] pieces, int columnStart, int rowStart, int columnEnd, int rowEnd) {
if( columnEnd==rowEnd && (pieces[rowStart][columnStart].FindPiece(chessPiece).charAt(0)!=pieces[rowStart+1][columnStart-1].FindPiece(chessPiece).charAt(0)) || pieces[rowStart][columnStart].FindPiece(chessPiece).charAt(0)!=pieces[rowStart+1][columnStart+1].FindPiece(chessPiece).charAt(0) || (pieces[rowStart][columnStart].FindPiece(chessPiece).charAt(0)!=pieces[rowStart-1][columnStart-1].FindPiece(chessPiece).charAt(0) || pieces[rowStart][columnStart].FindPiece(chessPiece).charAt(0)!=pieces[rowStart-1][columnStart+1].FindPiece(chessPiece).charAt(0))){
valid5=true;
}
else{
valid5=false;
}
}
as you can see in the condition. the FindPiece method is inside the "isMoveValid" method.
is that legal?