vendredi 2 octobre 2015

Giving an object random stats

I've been wanting to make a text rpg for awhile now, but finally got around to starting making some objects and classes for a small prototype. I want to make a bunch of enemies, but without imputing stats for all of them individually, I decided to use java util.Random in order to generate a random int between 1-100 but when I look at the objects integers in my main test file theyre all 0. The l(); method is just a method i made without a printout in it with an object to save me some time. The stat value will give me a random number but the l(goblin.health); remains 0. Any advice on how to solve this?

Random stats = new Random(); 
int stat = stats.nextInt(100);
l(stat);

enemies goblin = new enemies(stat,stat,stat,stat);
l(goblin.health);




Aucun commentaire:

Enregistrer un commentaire