lundi 8 octobre 2018

Else if chain wont loop through properly

I have to make a project modeling the monty hall gameshow for my high school java class.... though I have run into an error... running though this code, no matter what the choice or the goatSpot is.. this set of code always outputs the choice as 2

    if (switchChoice.equals("YES"))
    {        

        if (choice == 1 && goatSpot == 3)
        {
            choice = 2;
        }
        else if (choice == 1 && goatSpot == 2)
        {
         choice = 3;
        }            
        else if (choice == 2 && goatSpot == 3)
        {
            choice = 1;
        }
        else if (choice == 2 && goatSpot == 1)
        {
            choice = 3;
        }
        else if (choice == 3 && goatSpot == 2)
        {
            choice = 1;
        }
        else if (choice == 3 && goatSpot == 1);
        {
            choice = 2;
        }
    }

Any ideas? Choice at the end of the chain here is always 2 regardless of what is thrown into it...

Aucun commentaire:

Enregistrer un commentaire