I am looking for a way to generate a random value from a given input based of a seed. I'll give a code example for what I'm trying to achieve:
public class Seed {
public double generateRandom(double input) {
// What goes in here?
}
}
This is how an example program could look like:
public static void main(String[] args) {
Seed seed1 = new Seed(), seed2 = new Seed();
System.out.println("Result of seed 1 with 69: " + seed1.generateRandom(69));
System.out.println("Result of seed 2 with 69: " + seed2.generateRandom(69));
System.out.println("Result of seed 1 with 420: " + seed1.generateRandom(420));
System.out.println("Result of seed 2 with 420: " + seed2.generateRandom(420));
System.out.println("Result of seed 1 with 69 is still: " + seed1.generateRandom(69));
System.out.println("Result of seed 2 with 69 is still: " + seed2.generateRandom(69));
}
The output being:
Result of seed 1 with 69: 0.5
Result of seed 2 with 69: 0.65
Result of seed 1 with 420: 0.2
Result of seed 2 with 420: 0.34
Result of seed 1 with 69 is still: 0.5
Result of seed 2 with 69 is still: 0.65
What would the Seed class look like?
Aucun commentaire:
Enregistrer un commentaire