我一直遇到一个错误,没有else的if。
我也尝试了else if。
如果你对如何呈现这段代码有更好的想法,请不要犹豫 :)
我也尝试了else if。
for (;;) {
System.out.println("---> Your choice: ");
choice = input.nextInt();
if (choice==1)
playGame();
if (choice==2)
loadGame();
if (choice==3)
options();
if (choice==4)
credits();
if (choice==5)
System.out.println("End of Game\n Thank you for playing with us!");
break;
else
System.out.println("Not a valid choice!\n Please try again...\n");
}
如果你对如何呈现这段代码有更好的想法,请不要犹豫 :)
if
语句都需要与else
连接起来。 - ᴇʟᴇvᴀтᴇ