samedi 5 septembre 2020

How do random object's seed work when passed into another class as a parameter? Is the seed the same if I store it in a new object?

In my class I am working on building a snake game app. I have pretty much completed it and it works as intended. The jar file they use to run the application creates a random object and passes it to a constructor in my class which takes it as a parameter. Since I will use it to generate a new location (x,y) position of the item that the snake eats, I created a new random object so it could be set to the random parameter. In another method I pass nextInt(bound) for each X, Y. My main concern is that I think the testing software wants to know the seed so it can verify that my program works. My concern is that the random object that I created has a different seed than the passed in random parameter does. Is that the case? or does it essentially copy the seed? I have included screenshots.

Picture of the new random parameter being sent to my constructor

picture of my constructor with the new random being created and set to the parameter




Aucun commentaire:

Enregistrer un commentaire