public class FancyDoublyLinkedList extends DoublyLinkedList implements List, FancyList, FancyCollection { //Constructor public FancyDoublyLinkedList() { super(); } //List methods - inherited from class DoublyLinkedList //FancyList methods implementation public boolean containsAll(FancyList c) { throw new UnsupportedOperationException(); } public boolean addAll(FancyList c) { throw new UnsupportedOperationException(); } public boolean addAll(int index,FancyList c) { if(index < 0 || index > size()) throw new java.lang.IndexOutOfBoundsException(); int s = size(); Iterator it = c.iterator(); while(it.hasNext()) add(index++,it.next()); return s < size(); } public boolean removeAll(FancyList c) { int s = size(); Iterator it = c.iterator(); while(it.hasNext()) { Object temp = it.next(); boolean flag = true; while(flag){ flag = false; if(remove(temp) != null) flag = true; } } return s > size(); } public boolean retainAll(FancyList c) { throw new UnsupportedOperationException(); } public FancyList subList(int fromIndex,int toIndex) { throw new UnsupportedOperationException(); } //FancyCollection methods implementation public void clear() { setHead(new DNode()); setTail(new DNode()); getTail().setLeft(getHead()); getHead().setRight(getTail()); setNum(0); } public Object[] toArray() { throw new UnsupportedOperationException(); } public Object clone() { throw new UnsupportedOperationException(); } public boolean equals(Object arg) { throw new UnsupportedOperationException(); } } class TestFancyDoublyLinkedList { public static void main(String[] args) { FancyDoublyLinkedList A = new FancyDoublyLinkedList(); for(int i = 10; i <= 20; i++) A.add(new Integer(i)); System.out.println(" FancyDoublyLinkedList A:"); System.out.println(A); FancyDoublyLinkedList B = new FancyDoublyLinkedList(); for(int i = 15; i <= 25; i++) B.add(new Integer(i)); System.out.println(" FancyDoublyLinkedList B:"); System.out.println(B); A.addAll(3,B); System.out.println(" FancyDoublyLinkedList A = A.addAll(3,B):"); System.out.println(A); A.removeAll(B); System.out.println(" FancyDoublyLinkedList A = A.removeAll(B):"); System.out.println(A); FancyDoublyLinkedList C = (FancyDoublyLinkedList)A.subList(1,3); System.out.println(" FancyDoublyLinkedList C = A.subList(1,3):"); System.out.println(C); A.retainAll(C); System.out.println(" FancyDoublyLinkedList A = A.retainAll(C):"); System.out.println(A); } }