// CSE 143, Winter 2009, Marty Stepp // This class captures common code shared by both the ArrayAnythingList // and LinkedAnythingList. // An abstract class is a good way to provide a partially implemented class, or // a partial implementation of an interface. Notice that the header of this // class claims to implement the AnythingList interface, but the file doesn't // write all of the methods. Java allows this file to compile because it knows // the abstract class must be extended to complete it. If a subclass of // AbstractAnythingList doesn't implement all the rest of the AnythingList // interface's methods, that subclass will not compile. public abstract class AbstractAnythingList implements AnythingList { // Adds the given value to the end of the list. public void add(E value) { add(size(), value); } // Returns true if this list contains the given value as an element. public boolean contains(E value) { return indexOf(value) >= 0; } // Returns true if there are no elements in this list. public boolean isEmpty() { return size() == 0; } }