I have the following code:
public class SeleccionFutbol{
protected int carnetIdent;
protected String nombre;
protected String apellidos;
protected int edad;
public SeleccionFutbol(int id, String n, String a, int edad){
carnetIdent = id;
nombre = n;
apellidos = a;
this.edad = edad;
}
//getters y setters
}
and the subclasses:
public class Entrenador extends SeleccionFutbol{
private String codEntrenador;
public Entrenador(int id, String n, String a, int edad, String cod){
super(id,n,a,edad);
codEntrenador = cod;
}
//getters y setters
}
And I have an ArrayList of the Football Selection type, from which I must show the coach's data, which I did like this:
System.out.println("El entrenador que dirigira el partido es: ");
for(SeleccionFutbol s : integrantes){
if(s instanceof Entrenador){
System.out.println(s.getNombre() + " "+ s.getApellido() + ",edad: " + getEdad());
}
}
But I do not know how to show the coach's code.