/** * Simple class for storing a list of Strings. * Demonstration program for CSE 143. Starter code * @author Hal Perkins * @version 0.0, 3/28/06 */ public class StringList { // Object state //TODO // Default size of new lists private static final int defaultSize = 20; // constructors /** * Construct a new, empty StringList */ public StringList() { //TODO } // query functions /** * Return the size of this list * @return number of items currently in the list */ public int size() { return -1; //FIX } /** * Return the location of a string in this list * @param s the string to be located * @return the index of s in the list if it is there, otherwise -1 */ public int indexOf(String s) { //TODO // not found return -1; } /** * Return the list element at a given position in this list * @param pos position of desired element (must be 0 <= pos < size()) * @return the list element at that position */ public String get(int pos) { return "nogots"; //FIX } // string modifications /** * Add a new item to the end of this StringList. * pre: list is not full * @param s the string to add to the list */ public void add(String s) { //TODO } /** * Add the contents of another StringList to this list. * pre: there is enough room in this list for the contents of the other list * @param other the other StringList */ public void add(StringList other) { //TODO } /** * Remove the item at the specified pos from this list * @param pos position of the item to be removed (must be 0<=pos 0) { // result = result + items[0]; // } // for (int k = 1; k < size; k++) { // result = result + "," + items[k]; // } result = result + "]"; return result; } }