import java.awt.*; import javax.swing.*; import java.util.List; import java.util.Iterator; import java.util.Arrays; public class CouleurList implements Iterable { protected E[] valeurs; public CouleurList() { this.valeurs = (E[]) new Object[10]; } public CouleurList(E element) { this.valeurs = (E[]) new Object[10]; this.valeurs[0] = element; } public void add(E element) { for (int i = 0; i != this.valeurs.length; i++) { if (this.valeurs[i] == null) { this.valeurs[i] = element; break; } } } public boolean remove(E element) { for (int i = 0; i != this.valeurs.length; i++) { if (this.valeurs[i] != null && this.valeurs[i].equals(element)) { for (int j = i; j != this.valeurs.length-1; j++) { this.valeurs[j] = this.valeurs[j+1]; } this.valeurs[this.valeurs.length - 1] = null; return true; } } return false; } @Override public Iterator iterator() { return new Iterateur(this); } }