Overriding the equals and hashCode methods in ChessPiece.