My vex instructor has giving me a challenge. She wants me to make a piece of code that will allow the V5 brain to select between different phrases randomly and display them on the Brain. I have searched for two weeks and cant seem to find anything. I would assume you would have to use some sort of rand(select variable) or something like that. Do any of you have any ideas? any and all help is appreciated.
Ignoring programming for a moment, suppose I gave you a 6-sided die and I asked you to randomly tell me one of 6 phrases. How would you do it?
I would roll the die and then read the accosted phrase.
I think where @edjubuh is leading you is you need to define what you want your code to do.
- Create a list of phrases and 2) randomly pick one of the phrases.
Most programming languages store lists of things as an Array. Then you need a random number generator to pick one of the phrases.
Pseudo Code
phrases] = {"Hello","Hola","Bonjour","Ciao","Namaste","Salaam"};
myNum = Random(0,5);
Screen.Print(phrases[myNum]);
I think if you look at the VCS help files or do some searching in the internet using the bold keywords you may start to figure out your code. When searching be sure to include what programming language you are using like c++ or python.