lundi 20 février 2017

What is the Qt way of doing a random switch function that never uses the same case twice in a row?

I'm assuming the code should look something like this:

QString Boat::programming()
{
    int rand = ???; 
    switch (rand) {
    case 1:
        return function1();
    case 2:
        return function2();
    case 3:
        return function3();
    case 4:
        return function4();
    case 5:
        return function5();
    default:
        return "";
    }
}

Requirements:

  • When I call the function a second or third time, rand can not use the same value it had last time, or the time before.
  • Must use Qt's framework.

How should I go about this?




Aucun commentaire:

Enregistrer un commentaire