これは私の他の質問に関連しています
public void equipWep(String weapontoequip){
if(items.isEmpty() && weapons.isEmpty()){
System.out.println("You are not carrying anything.");
} else {
boolean weaponcheck_finished = false;
do {
for (String s : weapons) {
if (s.contains(weapontoequip)) {
System.out.println("You equip " + s + ".");
weaponcheck_finished = true;
} else {
System.out.println("You cannot equip \"" + weapontoequip + "\", or you do not have it.");
weaponcheck_finished = true;
}
}
}while(weaponcheck_finished == false);
}
}
このメソッドを実行すると、システムは何も出力しません。一連の印刷テストを通して、私はそれがdo-while
ループの内側に入ると判断しました。for
しかし、それがループの中に入るのかどうかはわかりません。