I am working on making a text based game in Java, I am using a class and instance variables and I am trying to create a method that generates a random number based on the number that the instance variable max_attack
has.
public class badPlayer
{
String description;
int health;
int award;
int max_attack;
public badPlayer(String description, int health, int award, int attack){
this.description=description;
this.health = health;
this.award = award;
this.max_attack = attack;
}
Random rnd = new Random();
public int maxAttack(){
int rand_int1 = rnd.nextInt(max_attack);
return rand_int1;
}
}
public class troll extends badPlayer
{
troll(int attack){
super("troll", 100, 50, 100);
}
}
Output
troll1005089
I would like the method to create random numbers between 1 and 100.