lundi 4 mai 2015

Generating several random double numbers in java

Every time when I try to generate random coordinates of city in this way,

public City () {                    
        super();
        this.x = Math.random()*200;
        this.y = Math.random()*200;
    }

I get the same values for the X and Y, which means that all cities are on same line on map. My question is how to avoid this? How to create different coordinates? Thanks.




Aucun commentaire:

Enregistrer un commentaire