私のコードはエラーがないかのようにコンパイルされますが、実行すべきコードは本当に実行されません。助けてください。パラメータが真であっても私の "if文"は実行されません
public static void newGameCheck() {
String newCharacter = scan.next();
if (newCharacter.equals("New game")) {
//more code here, but it does not get executed for some reason
}
そして、もう一つの例はここにある:ここで
public static void warriorTurn() {
if (warriorAlive==true) {
etut.choosingTarget();
int target= scan.nextInt();
System.out.println("Now type in which ability you want him to use, make sure to use capitals");
warrior_Weapons_and_Abilities();
String ability= scan.next();
if (ability.equals("Anduril, Foe of Terror")) {
int damage= 100+((int) (Math.random()*50));
etut.loseHealth(target, damage);
mana2=mana2-0;
etut.displayHealth(target);
}
else if (ability.equals("Aethereal Blades")) {
int damage= 250+((int) (Math.random()*100));
etut.loseHealth(target, damage);
mana2=mana2-2;
etut.displayHealth(target);
}
else if (ability.equals("Potion")) {
health2=health2+100;
mana=mana-0;
etut.displayHealth(target);
}
^私は能力名を入力するたびに、コードがまだscan.nextLine()
に
質問に関連する言語タグを追加してください。 –
デバッガでコードをステップ実行しましたか? – OldProgrammer
プログラムをデバッグしてください。 – f1sh