Skip to content
Snippets Groups Projects
Commit 620db9c5 authored by Guyslain's avatar Guyslain
Browse files

section 8 Cell fini

parent 11d9207d
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ import java.util.List;
*/
public class Cell<T> implements Lens<T> {
//TODO: ajouter la ou les propriétés nécessaires
private T content;
// la liste des objets écoutant les modifications du contenu de la cellule
private final List<OnChangeListener<T>> listeners = new ArrayList<>();
......@@ -23,7 +23,7 @@ public class Cell<T> implements Lens<T> {
* @param initialContent the value initially stored by the cell.
*/
public Cell(T initialContent) {
//TODO: à compléter
this.content = initialContent;
}
/** Add a {@link OnChangeListener} to react to any change of value in the cell.
......@@ -42,8 +42,11 @@ 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 = this.content;
this.content = value;
for (OnChangeListener<T> listener : this.listeners) {
listener.valueChanged(oldValue,value);
}
}
/**
......@@ -52,7 +55,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 this.content;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment