mardi 24 novembre 2015

Passing random.nextInt() as a parameter causes strange problems

I am trying to pass a random integer to a constructor.

hotels[2] = new Hotel(random.nextInt(10)+30, random.nextInt()+100, 
                random.nextInt()+20, random.nextInt()+200, 
                random.nextInt()+10, random.nextInt()+300);

However, in the DataPoint constructor, the values being passed inside were ridiculous, i.e.

Params 1, 3, 5:      38   -695807826   -2078518332

Getting -695807826 makes no sense. The number should be between 20 and 40, because of random.nextInt()+20




Aucun commentaire:

Enregistrer un commentaire