mardi 24 janvier 2017

multiple if statements and a loop

I have a logical problem. I will provide pseudo code since the real code isn't all that readable. I wan't to only enter one of the instructions, and if none of the instructions are reachable I wan't the function to break out from the loop.

I'm pretty new to programming so any help is appreciated.

while(true){
     if(condition){ // Instruction 1
        do stuff
    }else{
        do stuff
    }
    if(condition){ // Instruction 2
        do stuff
    }else{
        do stuff
    }
    if(condition){ // Instruction 3
        do stuff
    }else{
        do stuff
    }

    if(condition){ // Instruction 4
        do stuff
    }else{
        do stuff
    }

    if(none condition){
        break;
    }
}

Aucun commentaire:

Enregistrer un commentaire