i'm having trouble writing a function that will get a number and will return a random number in the range between the input and a const number, for example: I enter 5, and the cost is 100, so the function should return a number between 5-100, and when I enter 50, it should return between 50-100: this is my function so far:
public double stopPoint(double d) {
Random rand = new Random();
if(d>0) {
return Math.random() * ((this.finish.getX()-50) - d );
}
}
this.finish.getX is the constant number for example 100, and d is the input, but it doesnt seem to work, anybody knows why?
Aucun commentaire:
Enregistrer un commentaire