Skip to content
Snippets Groups Projects
Commit 737e8785 authored by AREZKI Celia's avatar AREZKI Celia
Browse files

MotorizedFirefighter : add the methode updateFireFighter

parent bf40c349
No related branches found
No related tags found
No related merge requests found
package model; package model;
public class MotorizedFirefighter { import util.Position;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class MotorizedFirefighter extends FirefighterManager {
public MotorizedFirefighter(List<Position> firefighterPositions) {
super(firefighterPositions);
}
@Override
public List<Position> updateFirefighters(int step, Map<Position, List<Position>> neighbors) {
List<Position> modifiedPositions = new ArrayList<>();
for (Position firefighterPosition : firefighterPositions) {
// Déplacement motorisé, on se déplace de deux cases
Position newFirefighterPosition = moveToTarget(firefighterPosition, fireManager.getFirePosition(), neighbors);
setFirefighterPosition(firefighterPosition, newFirefighterPosition);
// Vérifier si un feu est à la nouvelle position et l'éteindre
if (fireManager.isOnFire(newFirefighterPosition)) {
extinguishFire(newFirefighterPosition);
}
modifiedPositions.add(firefighterPosition);
modifiedPositions.add(newFirefighterPosition);
}
return modifiedPositions;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment