import java.util.Random;
public class Fighter {
int str;
int dex;
int hth;
Random gen = new Random(1535636);
public Fighter() {
str = gen.nextInt(9);
dex = gen.nextInt(9);
hth = gen.nextInt(14);
}
public int getHth(){
return hth;
}
public int getStr(){
return str;
}
public int getDex(){
return dex;
}
}
import java.util.Random;
public class Arena {
public static void main(String[] args) {
Random gen = new Random();
Fighter Guy1 = new Fighter();
int x =1;
while (x < 200000000){
x++;
}
Fighter Guy2 = new Fighter();
int hth1 = Guy1.getHth();
int hth2 = Guy2.getHth();
System.out.println("Fight Start");
System.out.println("---------------");
//System.out.println(gen.nextInt(10));
//System.out.println(gen.nextInt(17));
System.out.println(Guy1.getStr());
//Fighting
}
}
Whenever i run this i get the same results no matter what. I'd like it to make 2 random fighters each time. Right now theres a few lines that were just to confirm that it doesn't make random numbers.
Does anyone know how to use random numbers in a constructor properly? or am i doing this completely wrong?