I tried to apply the this() method for calling the same constructor in java for trying to make a constructor wehere just vy providing the name and the class it would select the parameters of the character but its not working, im new to using this in java.
type public class Jugador{
//campos
private String nombre;
private String clase;
private int vida;
private int ad;
private int ap;
private int def;
private int mr;
//constructores
private Jugador(String nombre, String clase, int vida, int ad, int ap, int def, int mr){
this.nombre = nombre;
if (clase.equals("hunter") || clase.equals("warrior") || clase.equals("assasin") || clase.equals("tank")){
this.clase = clase;
}
else{
this.clase = "normal";
}
this.vida = vida;
this.ad = ad;
this.ap = ap;
this.def = def;
this.mr = mr;
}
public Jugador(String nombre, String clase){
if (clase.equals("hunter")){
this(nombre, clase, 120, 50, 0, 40, 0);
}
else if (clase.equals("warrior")){
this(nombre, clase, 100, 70, 0, 80, 0);
}
else if (clase.equals("assasin")){
this(nombre, clase, 60, 120, 0, 20, 0);
}
else if (clase.equals("tank")){
this(nombre, clase, 200, 20, 0, 80, 0);
}
else if(clase.equals("normal")){
this(nombre, clase, 80, 80, 0, 80, 0);
}
}
}here