package model.cellule.créateur; import javafx.beans.property.ListProperty; import javafx.beans.property.SimpleListProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import model.CellulesVivantes; import model.cellule.Cellule; import java.util.LinkedList; import java.util.List; public class CreateurCellule implements ICreateurCellule { private int w; private int h; public CreateurCellule(int w, int h) throws IllegalArgumentException{ if(w<0 || h<0){ throw new IllegalArgumentException("La longueur et la largeur doivent être supperieur à 0"); } this.w = w; this.h = h; } public ListProperty> creerCellules(CellulesVivantes observer){ return creerCellules(w, h, observer); } public ListProperty> creerCellules(int colone, int ligne, CellulesVivantes observer){ ObservableList> cellsInit = FXCollections.observableArrayList(); ListProperty> cells = new SimpleListProperty<>(cellsInit); List tmp; Cellule c; for (int i = 0; i < ligne; i++) { tmp = new LinkedList<>(); for (int j = 0; j < colone; j++) { c = new Cellule(j, i); c.attacher(observer); tmp.add(c); } cells.add(tmp); } return cells; } public List creerLigneCellule(int ligne){ List cells = new LinkedList<>(); for(int i=0; i