public abstract class Sequence 
{ protected int length=0;
  
  public int getLength()
  { return length;
  }
  
  public abstract void append(Object object);
  // adds the given object to end of this sequence
  
  public int count(Object object)
  { int c=0;
    for (int i=0; i<getLength(); i++)
      if (object.equals(get(i))) ++c;
    return c;
  }
  public abstract Object get(int index);
  // returns the object at the given index,
  // or null if it is not in this sequence
  
  public int indexOf(Object object)
  { for (int i=0; i<length; i++)
      if (object.equals(get(i))) return i;
    return -1;
  }
  
  public abstract Object remove(int index);
  // removes and returns the object at the given index,
  // or returns null if index >= length;
  
  public abstract boolean remove(Object object);
  // removes the first occurrence of the the object;
  // returns thre iff successful;
  
  public abstract Object set(int index, Object object);
  // returns the object at the given index after replacing
  // it with the given object, or null is unsuccessful 

  public String toString()
  { if (length==0) return "()";
    String s = "(" + get(0);
    for (int i=1; i<length; i++)
      s += "," + get(i);
    return s + ")";
  }
}
