newRandom function
Generates a new random number from 0 to 8, to determine which of the symbols in the symbol list is going to display in the middle of the screen.
In the trial test, first all the nine symbols are displayed once each, and then switches to complete random mode.
The arguments are:
currentId is the number of the symbol that is on the screen at the moment.
isTrial is a boolean that is true if the running test is the trial.
counter counts the number of symbols that have been displayed in the middle
since the start of the test, only in the trial test.
order is a list of integers that determines the sequence of the first nine
symbols that are to be displayed in the middle.
First the code checks if it is trial test and not less than nine symbols have been displayed. If so, it shows the corresponding symbol in the sequence. IF it is not trial or the nine symbols have already been showed, it generates a new random symbol with the only condition of being different from the current one.
Implementation
int newRandom(int currentId, bool isTrial, int counter, List<int> order) {
if(isTrial && counter < 9){
return order[counter];
}
else {
final random = Random();
int randomNumber;
do {
randomNumber = random.nextInt(9);
} while (randomNumber ==
currentId); //Nos aseguramos de que cambie el simbolo
return randomNumber;
}
}