I am doing a project for my CHS Java course that models the Monty Hall gameshow. But for some reason, this if statement wont 'activate' even though it is true... any ideas?
System.out.println("There is a goat behind Door #" + (goatSpot));
System.out.println("Would you like to switch your door? (yes or no) ");
String switchChoice = input.next();
switchChoice = switchChoice.toUpperCase();
if (switchChoice == "YES")
{
if (choice == 1 && goatSpot == 2)
{
choice = 3;
}
else if (choice == 1 && goatSpot == 3)
{
choice = 2;
}
else if (choice == 2 && goatSpot == 3)
{
choice = 1;
}
else if (choice == 2 && goatSpot == 1)
{
choice = 3;
}
else if (choice == 3 && goatSpot == 1);
{
choice = 2;
}
if (choice == 3 && goatSpot == 2)
{
choice = 1;
}
}
It just completely ignores everything inside the if statement....
Aucun commentaire:
Enregistrer un commentaire