現在、敵(バット)の健康が低下するはずですが、機能していないゲームのこのコードをコーディングしています。変数を変更しようとしているJavaメソッドが機能していません
class BatTest{
public static void main(String args[]) {
String input = "";
boolean exit = false;
Bat bat1 = new Bat();
Inventory MainInv = new Inventory();
MainInv.smallknife = true;
System.out.println("A bat has appeared!");
System.out.println("Health: " + bat1.health + " Attack Strength: " + bat1.damage);
do{
System.out.println("Health: " + bat1.health + " Attack Strength: " + bat1.damage);
System.out.print("What would you like to do: ");
input = Keyboard.readString();
if (input.equalsIgnoreCase("Attack")) {
Abilities.smallknifeMA(bat1.health);
System.out.println(bat1.health);
}
else if (input.equalsIgnoreCase("exit")) {
exit = true;
}
}while(!exit);
}
}
//enemyH denotes the health of the enemy
class Abilities {
static double smallknifeMA(double enemyH) {
enemyH = enemyH - 2.0;
return enemyH;
}
}
class Inventory {
boolean smallknife;
boolean startlockerkey;
}
smallknifeMAが変数bat1.healthを下げない理由私は本当に理解することはできません。
おかげで、 オーロラ
おそらく、何がうまくいかないかについての情報を提供しているかもしれません。何が起きているのかをデバッガで見てみましたか? – dman2306