I'm trying to assign an array element obtained through random indexing to a variable.
next = ringG.road[next].entPoint = ringG.entArray[(int) (Math.random()*4)];
ringG.road[next].extPoint = ringG.extArray[(int)(Math.random()*4];
So for some reason the above two statements do not evaluate the same way, despite what I believe to be correct use of the assignment operator. It should read from right to left, correct? So the top line first assigns the array value to .entPoint and then assigns that to next.
When I print this information to the console, every single 'entPoint' value is 0 while the 'extPoints' contain the values as dictated in extArray.
FURTHERMORE, the applet this code runs is doing the OPPOSITE of what I'd expect. It's a vehicle simulation, and ent/ext refer to cars coming in and out of my system at specific points. They're entering randomly despite the value of 'entPoint' being 0 and all exiting at the same spot (the value declared in the constructor for the .roadway[]), despite the seeming value being the desired exit point.
Can anybody explain either of these issues?
Aucun commentaire:
Enregistrer un commentaire