/**
 * An incomplete implementation of a reverse sorted list.
 * Items are stored in an order opposite to that of their natural ordering.
 * Natural order is determined by Comparable's compareTo method.
 * (In other words, items are stored from greatest-to-least rather than
 * in the normal least-to-greatest order.)
 */
public class ReverseSortedList<E extends Comparable<E>> {

  private Node<E> head;

  private String str = "";
  private Node<E> curr;

  /** Adds an element to the appropriate location in this List. */
  public void add(E item) {

    //...your code here...

  }

  @Override
  public String toString() {
    curr = head;
    while (curr != null) {
      str += curr.getData() + " ";
      curr = curr.getNext();
    }
    return str;
  }


  public static void main(String[] args) {
    ReverseSortedList<String> names = new ReverseSortedList<String>();
    names.add("Doug");
    names.add("Abe");
    names.add("Chris");
    names.add("Ben");
    names.add("Fred");
    System.out.println("[Fred Doug Chris Ben Abe ] =?= [" + names + "]");

    ReverseSortedList<Integer> nums = new ReverseSortedList<Integer>();
    nums.add(5);
    nums.add(7);
    nums.add(2);
    nums.add(8);
    nums.add(6);
    System.out.println("[8 7 6 5 2 ] =?= [" + nums + "]");

    //System.out.println(nums);  //Should still be: 8 7 6 5 2
    //System.out.println(nums);  //Should still be: 8 7 6 5 2
  }
}