public class ChainePile implements Pile { private Chaine lastChain; public ChainePile() {} @Override public E getFirst() { if (lastChain != null) { return lastChain.getValue(); } else { return null; } } @Override public E pollFirst() { if (lastChain != null) { E value = lastChain.getValue(); lastChain = lastChain.getNext(); return value; } else { return null; } } @Override public void addFirst(E e) { Chaine link = new Chaine(); link.setValue(e); link.setNext(lastChain); lastChain = link; } @Override public int size() { int count = 0; Chaine curr = lastChain; while (curr != null) { curr = curr.getNext(); count++; } return count; } }