【发布时间】:2020-06-30 18:15:34
【问题描述】:
我如何检查是否选择案例(例如 3 )来继续故事? 我用java写了这个,我会详细介绍故事,但我不知道我该怎么做。我想我可以将案例相互嵌套,但如果我可以选择选项(scanner.nextInt();)也可以添加它们。我认为如果声明会更好,但我不知道如何检查它。我必须补充一点,在发布之前没有找到这个问题的任何答案。感谢您的审查,祝您有美好的一天
int choice_1 = scanner.nextInt();
switch(choice_1)
{
case 1:
System.out.println("Guard: Its a honor to meet u sir.Its a pleasure to let You through \nBut do u have coin pass?");
if(pass==1){
ending();
}
else{"You should get coin pass first. I am sure that wont be a problem for Prince *laughs*"}
break;
case 2:
System.out.println("*Guard immediately avoided attack and attack u harder that u excepted");
playerHp = playerHp -30;
playerArmorHp = playerArmorHp - 50;
break;
case 3:
System.out.println("Guard : Goodbye Sir");
plan();
break;
default:
System.out.println("Guard is impatient of your not telling anything.Choose option before making him mad.\n"+line);
break;
}
if(switch ( case:3)){
System.out.println("Do u have coin pass?");
int pass = scanner.nextInt();
}
【问题讨论】:
标签: java if-statement switch-statement