import java.util.Iterator; /** * A simplified of the interface java.util.List. * This interface contains fewer methods, the * method specifications are simplified and the * elements of the list are strings. * * @author Franck van Breugel */ public interface List { /** * Appends the specified element to the end of this list. * * @param element a string. * @pre. element != null * @return true */ boolean add(String element); /** * Returns the element at the given position in this list. * * @param index index of the element to return. * @pre. index >= 0 && index < size() * @return the element at the given position in this list. */ String get(int index); /** * Replaces the element at the given position in this list with the * given element. Returns the element previously at the specified * position. * * @param index index of the element to replace. * @pre. index >= 0 && index < size() * @param element element to be stored at the given position. * @pre. element != null * @return the element previously at the specified position. */ String set(int index, String element); /** * Returns the number of elements in this list. * * @return the number of elements in this list. */ int size(); /** * Returns a string representation of this list. The string * representation consists of a list of the elements in the * order they are returned by its iterator, enclosed in square brackets * ("[]"). Adjacent elements are separated by the characters * ", " (comma and space). * * @return a string representation of this collection. */ String toString(); /** * Tests if this list contains the given element. * * @param element a string. * @pre. element != null * @return true if this list contains the given element, * false otherwise. */ boolean contains(String element); }