Skip to content
Snippets Groups Projects
Commit 9f1d562b authored by Sarah CHERCHEM's avatar Sarah CHERCHEM
Browse files

MotorizedFactory : implements the methode createElements

parent ac99b799
Branches
No related tags found
No related merge requests found
package model; package model;
public class MotorizedFactory { import util.Position;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class MotorizedFactory implements ElementFactory<MotorizedFireFighter>, PositionGenerator{
private final Random random;
private int count;
public MotorizedFactory(Random random, int count) {
this.random = random;
this.count = count;
}
@Override
public List<MotorizedFireFighter> createElements(int rowCount, int columnCount) {
List<MotorizedFireFighter> firefighters = new ArrayList<>();
for (int i = 0; i < count; i++) {
Position randomPosition = generateRandomPosition(rowCount, columnCount);
firefighters.add(new MotorizedFireFighter(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