我正在为我的CHS Java课程做一个项目,该项目为Monty Hall游戏节目建模。但是出于某种原因,即使是真的,这个if语句也不会“激活” ...有什么想法吗?
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;
}
}
它只是完全忽略了if语句中的所有内容。...