I am making a chess game and trying to figure out if there is a way to make my abstract class "Piece" have a method that returns a new instance of the concrete implementations like Pawn or Rook.
For example:
static public Piece newNorthPiece(){
return new Piece(true);
}
Except instead of returning a Piece I want it to return whatever the class that called the method is. So if I call Pawn.newNorthPiece() I want it to return to me a new Pawn(true). And I would like to do this without having to write a new factory method for every class that extends the Piece class.