Well, first I want to explain that I'm from Colombia so my English isn't very good.
Okay, it supossed i have to ask the user how many warriors does he wants in the world, I try to do it with an Greenfoot.ask()
and then convert it to an int with Integer.parseInt(), but it keeps sending me the error : java.lang.NumberFormatException: null
the code is this:
public void randomGuerreros(){
int value = Integer.parseInt(Greenfoot.ask("Cuantos guerreros"));
for(int i=0; i<value; i++) {
int x = Greenfoot.getRandomNumber(getWidth());
int y = Greenfoot.getRandomNumber(getHeight());
if (i%2==0){
Guerrero guerrero = new Guerrero("azul");
addObject(guerrero, x, y);
guerrero.setTribu();
}
else{
Guerrero guerrero = new Guerrero("rojo");
addObject(guerrero, x, y);
guerrero.setTribu();
}
}
}
