// Hunter Schafer, CSE 143 // This class provides a skeletal implementation of the List interface // to minimize the effort required to implement it. // Abstract classes are a good way to provide a partially implemented class. // This class compiles despite not implementing all of the List interface's methods // because abstract classes can't be directly instantiated and must instead be extended. // A subclass of AbstractList that doesn't implement the rest of the List interface will // not compile. public abstract class AbstractList implements List { /* * Can't do this! * AbstractList list = new AbstractList(); * */ // Can define your own abstract methods your children must implement // public abstract void destroy(); // Adds the given value to the end of the list. public boolean add(E value) { return add(size(), value); } // Returns true if the value is in the list, false otherwise. public boolean contains(E value) { return indexOf(value) != -1; } // Returns true if list is empty, false otherwise. public final boolean isEmpty() { return size() == 0; } }