53 lines
1.1 KiB
Java
53 lines
1.1 KiB
Java
import java.util.Objects;
|
|
import java.util.LinkedList;
|
|
import java.util.Deque;
|
|
|
|
|
|
/**
|
|
* Implémentation de l'interface MinimalDeque
|
|
*
|
|
* sert uniquement à tester les tests
|
|
* contrairement au sujet de Luc "Huck" Hernandez, fonctionne par délégation à un attribut
|
|
* implémentant Deque (ici une LinkedList)
|
|
*
|
|
* @author Florent Madelaine
|
|
* @see Java.util.Deque
|
|
*/
|
|
public class SimpleDequeThatsNotCricket<E> implements MinimalDeque<E>{
|
|
|
|
/**
|
|
* attribut à qui on va déléguer le travail.
|
|
*/
|
|
private Deque<E> d;
|
|
|
|
public SimpleDequeThatsNotCricket(){
|
|
this.d = new LinkedList<E>();
|
|
}
|
|
|
|
public void addFirst(E e){
|
|
Objects.requireNonNull(e, "e must not be null");
|
|
this.d.addFirst(e);
|
|
}
|
|
|
|
public void addLast(E e){
|
|
Objects.requireNonNull(e, "e must not be null");
|
|
this.d.addLast(e);
|
|
}
|
|
|
|
public boolean isEmpty(){
|
|
return this.d.isEmpty();
|
|
}
|
|
|
|
public E removeFirst(){
|
|
return this.d.removeFirst();
|
|
}
|
|
|
|
public E removeLast(){
|
|
return this.d.removeLast();
|
|
}
|
|
|
|
public String toString(){
|
|
return this.d.toString();
|
|
}
|
|
}
|