0
Story.direct3();
br.readLine();
Story.des();
try{
short choice1 = Short.parseShort(br.readLine());
switch(choice1){
case 1:
Display.yes();
br.readLine();
Story.rid();
String answ = br.readLine();
if ("Gravity".equals(answ) || "gravity".equals(answ)){
Display.correct();
Short choice2 = Short.parseShort(br.readLine());
switch(choice2){
case 1:
break;
}
}
else{
int less = player.hp - 10;
System.out.println("Wrong answer! Your hp will be lessen by 10. The correct answer is : 'Gravity'");
System.out.println("Your remaining HP is: " + less + "[press enter to continue...]");
br.readLine();
Story.wrong();
br.readLine();
}
break;
case 2:
Story.wrong1();
br.readLine();
break;
}
break;
}
catch(NumberFormatException ex){
System.out.println("Would you like to change your battle item?"
+ "\n[1] Yes"
+ "\n[2] No");
}
我刚开始编写Java代码近2个月,问我的朋友的代码,并试图尝试就可以了。事情是我不知道如何把try/catch。我错过了什么吗?的try/catch似乎我不知道在哪里把它
你在哪里需要它?代码现在有什么问题?请多解释一下你遇到的问题。 –
@SamiKuhmonen当我输入错误的答案时,玩家应该可以装备战斗物品。这就是“你想改变你的战斗项目吗?”出来。我应该怎么做? –