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

correction of FireFactory class

parent 9b68af80
No related branches found
No related tags found
No related merge requests found
Pipeline #41357 failed
package model;
import util.Position;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class FirefighterFactory implements ElementFactory<FireFighter>, PositionGenerator{
private final Random random;
private int count;
public FirefighterFactory(Random random,int count) {
this.random = random;
this.count=count;
}
@Override
public List<FireFighter> createElements(int rowCount, int columnCount) {
List<FireFighter> firefighters = new ArrayList<>();
for (int i = 0; i < count; i++) {
Position randomPosition = generateRandomPosition(rowCount, columnCount);
firefighters.add(new FireFighter(randomPosition));
}
return firefighters;
}
@Override
public Position generateRandomPosition(int rowCount, int columnCount) {
int row = random.nextInt(rowCount);
int column = random.nextInt(columnCount);
return new Position(row, column);
}
public int getCount() {
return count;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment