OL,
I thought you were 'on your way' with Mack's offers above.
Quote:
any suggestion is appreciated
It's Sunday here, so I take the liberty of some short-cut answer....
I think you'll find 2/3 of a solution in a prior post:
viewtopic.php?t=2844&highlight=random+array (note these keywords... you may find other prior solutions too)specifically:
Quote:
words1 = "fish,cat,rat,mouse,house,boat,float".split(",")
This will make myWords[0] equal fish etc
IF YOU NEED the second array (words2) separately, then yes you will also need to define this - else fill the first array with these words as an when you need them.
To get a random word from an array use:
myRandomWord = words1[String.random(words1.length)]
Some further ideas:
- if you always place your correct answer as the first or last item in the array, you can manipulate your random-choosing process to select from 'words1.length -1' guided appropriately for beginning subset or ending subset.
- I would find it easy to select 3 random --- and then replace one of those element's value with the '0' or 'last' element (the 'correct one'). The other way Mack suggested was select 2, and then insert or join so as to always include the correct answer value.
I think that covers it, depending how you present or sequence the final 3 possible answers.