Skip to content
Snippets Groups Projects
Commit f8bfd13e authored by SAHIN Melis damla's avatar SAHIN Melis damla
Browse files

Compléter la classe Cell

parent 4d7ee610
No related branches found
No related tags found
No related merge requests found
package model;
import model.automata.GameOfLifeAutomaton;
import model.automata.GameOfLifeState;
import java.util.ArrayList;
import java.util.List;
......@@ -11,17 +14,16 @@ import java.util.List;
*/
public class Cell<T> implements Lens<T> {
//TODO: ajouter la ou les propriétés nécessaires
// la liste des objets écoutant les modifications du contenu de la cellule
private final List<OnChangeListener<T>> listeners = new ArrayList<>();
private T initialContent;
/** Initialize a new cell with a given value.
*
* @param initialContent the value initially stored by the cell.
*/
public Cell(T initialContent) {
//TODO: à compléter
this.initialContent = initialContent;
}
/** Add a {@link OnChangeListener} to react to any change of value in the cell.
......@@ -40,8 +42,12 @@ public class Cell<T> implements Lens<T> {
* @param value the new content of this {@link Cell}
*/
public void set(T value) {
//TODO: modifier le contenu de la cellule, puis appeler les méthodes valueChanged des
// listeners
T oldValue = initialContent;
initialContent = value;
for (OnChangeListener<T> L : listeners) {
L.valueChanged(oldValue, value);
}
}
/**
......@@ -50,7 +56,6 @@ public class Cell<T> implements Lens<T> {
* @return the current content of this {@link Cell}
*/
public T get(){
//TODO: à compléter
return null;
return initialContent;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment