//given as an example of your implementation, just starting out
//feel free to change this file
// (though remember to change the @author if you do!)

/**
 * A SortedList, currently implemented as a linked list of nodes.
 *
 * @author Zach Tomaszewski, for ICS211-1
 * @version 09 Oct 2003
 */
public class OrderedList implements SortedList {

  //These are all the instance variables you need
  // (and you could even do without size if you wanted to)
  private int size = 0;  //number of elements in the list
  private Node head;     //head of the linked list

  public boolean isEmpty(){
    return true;  //return to get it to compile
  }
    
  public int size(){
    return 0;  //return to get it to compile
  }
  
  /**
   * Duplicate items are supported.  See SortedList for more.
   */
  public void add(Comparable item) throws SortedListException {
    /*
      This method says it throws an exception, 
        but you do not actually have to throw one.
      Some implementations, such as array-based, could fill up the list
        storage space and so might not be able to add more elements.  
      A linked list implementation does not have this problem.
    */
  }
  
  public Comparable get (int position) throws SortedListException{
    return new Integer(3); //just to get it to compile for now
  }
  
 
  public void remove (int position) throws SortedListException{
  
  }
  
  /**
   * Removes only the first instance of the item in the list.
   * See SortedList for more.
   */
  public void remove (Comparable item) throws SortedListException{
  }
  

  public void removeAll(){
    //probably all you need to do
    head = null;
    size = 0;   
  }


  /**
   * Returns the list as a String with the given string
   * inserted between each element.  The inserted spacer
   * comes between each element, but does not occur at the end
   * of the list.
   *
   * @param spacer  placed between each element of the list; 
   *                " " and "\n" are good values for spacer.
   * @return  the list (and spacers) as a string       
   */
  public String toString (String spacer) {
    
    String list = "";
    
    try{
      int i;
      for (i = 1; i < this.size(); i++){ //doesn't include last element
        //not very efficient, esp for long lists
        list = list + this.get(i).toString() + spacer;
      }
      //now add last element without spacer; i == this.size() at end of loop
      list = list + this.get(i);
    }catch (SortedListException sle) {
      //we know we're in size range, so this should never happen
      //if it does, return whatever we have so far
    }finally {
      return list;
    }
  }

}//end class
