c++ switch statement reverts to default statement after three recursive runs
<p>The purpose of my switch statement is to take an input of randomly generated input from 0 to 7 to preform on of the seven task. This is my code:</p>

<pre><code>        switch(move)
    {
    case 0:
        //up
        movement = 1;
        next = vf.plv(x,y,movement,cp,np);
        //hit cell membrane
        if(next == 0)
        {
            move = vf.mv(0);
        }
        else 
        {   cout&lt;&lt;j&lt;&lt;"\t"&lt;&lt;x&lt;&lt;"\t"&lt;&lt;y+1&lt;&lt;endl;
            virus[j].setvpoint(x,y+1,j,movement);
            break;
        }
    case 1:
        //up-right
        movement = 2;
        next = vf.plv(x,y,movement,cp,np);
        //hit cell membrane
        if(next == 0)
        {
            move = vf.mv(1);
        }
        else 
        {
            cout&lt;&lt;j&lt;&lt;"\t"&lt;&lt;x+1&lt;&lt;"\t"&lt;&lt;y+1&lt;&lt;endl;
            virus[j].setvpoint(x+1,y+1,j,movement);
            break;
        }
    case 2:
        //right
        movement = 3;
        next = vf.plv(x,y,movement,cp,np);
        //hit cell membrane
        if(next == 0)
        {
            move = vf.mv(2);
        }
        else 
        {
            cout&lt;&lt;j&lt;&lt;"\t"&lt;&lt;x+1&lt;&lt;"\t"&lt;&lt;y&lt;&lt;endl;
            virus[j].setvpoint(x+1,y,j,movement);
            break;
        }
    case 3:
        //down-right
        movement = 4;
        next = vf.plv(x,y,movement,cp,np);
        //hit cell membrane
        if(next == 0)
        {
            move = vf.mv(3);
        }
        else 
        {
            cout&lt;&lt;j&lt;&lt;"\t"&lt;&lt;x+1&lt;&lt;"\t"&lt;&lt;y-1&lt;&lt;endl;
            virus[j].setvpoint(x+1,y-1,j,movement);
            break;
        }
    case 4:
        //down
        movement = 5;
        next = vf.plv(x,y,movement,cp,np);
        //hit cell membrane
        if(next == 0)
        {
            move = vf.mv(4);
        }
        else 
        {
            cout&lt;&lt;j&lt;&lt;"\t"&lt;&lt;x&lt;&lt;"\t"&lt;&lt;y-1&lt;&lt;endl;
            virus[j].setvpoint(x,y-1,j,movement);
            break;
        }
    case 5:
        //down-left
        movement = 6;
        next = vf.plv(x,y,movement,cp,np);
        //hit cell membrane
        if(next == 0)
        {
            move = vf.mv(5);
        }
        else 
        {
            cout&lt;&lt;j&lt;&lt;"\t"&lt;&lt;x-1&lt;&lt;"\t"&lt;&lt;y-1&lt;&lt;endl;
            virus[j].setvpoint(x-1,y-1,j,movement);
            break;
        }
    case 6:
        //left
        movement = 7;
        next = vf.plv(x,y,movement,cp,np);
        //hit cell membrane
        if(next == 0)
        {
            move = vf.mv(6);
        }
        else 
        {
            cout&lt;&lt;j&lt;&lt;"\t"&lt;&lt;x-1&lt;&lt;"\t"&lt;&lt;y&lt;&lt;endl;
            virus[j].setvpoint(x-1,y,j,movement);
            break;
        }
    case 7:
        //left-up
        movement = 8;
        next = vf.plv(x,y,movement,cp,np);
        //hit cell membrane
        if(next == 0)
        {
            move = vf.mv(7);
        }
        else 
        {
            cout&lt;&lt;j&lt;&lt;"\t"&lt;&lt;x-1&lt;&lt;"\t"&lt;&lt;y+1&lt;&lt;endl;
            virus[j].setvpoint(x-1,y+1,j,movement);
            break;
        }
    default:
            cout&lt;&lt;"Default"&lt;&lt;endl

    }
</code></pre>

<p><em>next = vf.plv(x,y,movement,cp,np)</em> is a function that will output a 0 or a 1 depending on the x and y coordinates. The x and y coordinates are input into a distance formula to determine the distance from the center and if the distance is 13 or greater then next will equal 0. If it equals 0,  <em>move = vf.mv(7)</em> function will generate a new number from 0 to 7 that will then be put back into this switch function</p>

<p>The issue that I am having is that the switch function will recursively generate a new number 3 times and then revert to the default statement instead of continuing until it finds a distance less than 13. I have tried doing a do while loop and it still has not worked. </p>

<p>What should be my next step to fix this issue?</p>

<p>Thank you in advance!</p>
