0
私は、それぞれの "ターン"(ターンが3馬すべてになる)の後に位相が1ずつ上がるコードセットを作成しています。しかし、私が実行して出力フェーズ最後にはいつも0に戻ってきます。この状況でフェーズの数を実装する最良の方法は何ですか?whileステートメントでカウントを実装する
while (horse1.getLocation() <= 250 && horse2.getLocation() <= 250 && horse3.getLocation() <= 250){
int phase = 0;
horse1.move(phase);
horse2.move(phase);
horse3.move(phase);
horse1.location++;
horse2.location++;
horse3.location++;
phase++;
}
ループの外側で 'int phase = 0;'を移動します。繰り返しごとに0にリセットします。 –