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

BoardFireFighterBehavior : modify the methode initialize

parent bbf1c974
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ public class BoardFireFighterBehavior implements BoardBehavior{
private Set<Position> firePositions;
private final ElementFactory<FireFighter> firefighterFactory;
private final ElementFactory<Fire> fireFactory;
private List<Position> cloudPositions;
private int step;
public BoardFireFighterBehavior(Map<Position, List<Position>> neighbors, ElementFactory<Fire> fireFactory ,ElementFactory<FireFighter> firefighterFactory) {
......@@ -21,20 +22,30 @@ public class BoardFireFighterBehavior implements BoardBehavior{
this.fireFactory = fireFactory;
}
public void initializeElements(int rowCount, int columnCount) {
// Utilisation de la factory pour créer les feux
public void initializeElements(ElementFactory<Fire> fireFactory,
ElementFactory<FireFighter> firefighterFactory,
ElementFactory<Cloud> cloudFactory,
int rowCount, int columnCount) {
// Feux
firePositions = new HashSet<>();
List<Fire> fires = fireFactory.createElements(rowCount, columnCount);
for (Fire fire : fires) {
firePositions.add(fire.getPosition());
}
// Utilisation de la factory pour créer les pompiers
// Pompiers
firefighterPositions = new ArrayList<>();
List<FireFighter> firefighters = firefighterFactory.createElements(rowCount, columnCount);
for (FireFighter firefighter : firefighters) {
firefighterPositions.add(firefighter.getPosition());
}
// Nuages
cloudPositions = new ArrayList<>();
List<Cloud> clouds = cloudFactory.createElements(rowCount, columnCount);
for (Cloud cloud : clouds) {
cloudPositions.add(cloud.getPosition());
}
}
private Position randomPosition(int rowCount, int columnCount, Random randomGenerator) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment