Skip to content
Snippets Groups Projects
Commit 3d01aa5b authored by plojolo's avatar plojolo
Browse files

Ajout AbstractFireFighters

parent 0e6d3029
No related branches found
No related tags found
No related merge requests found
......@@ -3,11 +3,11 @@ package model;
import util.Position;
import java.util.*;
public class FireFighters extends AbstractElements{
public abstract class AbstractFireFighters extends AbstractElements{
public List<Position> firefighterPositions;
public Fire fire;
public FireFighters(int columnCount, int rowCount, Fire fire){
public AbstractFireFighters(int columnCount, int rowCount, Fire fire){
firefighterPositions = new ArrayList<>();
this.columnCount = columnCount;
this.rowCount = rowCount;
......@@ -15,17 +15,7 @@ public class FireFighters extends AbstractElements{
}
public void nextMove(){
List<Position> firefighterNewPositions = new ArrayList<>();
for (Position firefighterPosition : firefighterPositions) {
Position newFirefighterPosition = neighborClosestToFire(firefighterPosition);
firefighterNewPositions.add(newFirefighterPosition);
fire.extinguish(newFirefighterPosition);
}
firefighterPositions = firefighterNewPositions;
}
public abstract void nextMove();
protected Position neighborClosestToFire(Position position) {
Set<Position> seen = new HashSet<>();
HashMap<Position, Position> firstMove = new HashMap<>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment