title: Doubly Linked List -Removal and Adding
body: <p>This is a class lab, and within it I am attempting to add, remove, etc. into a doubly linked list. I have what I believe to be correct with what I have. I am having problems figuring out how to remove an object if its not the beginning or end of the list. I am having similar issues with the add method. Any advice on where to go from here and comments on my current code is very appreciated.</p>
  
  <pre><code>public class Double&lt;T extends Comparable&lt;T&gt;&gt; implements ListInterface&lt;T&gt; {
  
  protected DLLNode&lt;T&gt; front; //Front of list
  protected DLLNode&lt;T&gt; rear; //Rear of list
  protected DLLNode&lt;T&gt; curPosition; //Current spot for iteration
  protected int numElements; //Number of elements in list
  
  public Double() {
      front = null;
      rear = null;
      curPosition = null;
      numElements = 0;
  }
  
  protected DLLNode&lt;T&gt; find(T target) {
      //While the list is not empty and the target is not equal to the current element
      //curr will move down the list. If curr becomes null then return null.
      //If it finds the element, return it.
      DLLNode&lt;T&gt; curr;
      curr = front;
      T currInfo = curr.getInfo();
      while(curr != null &amp;&amp; currInfo.compareTo(target) != 0) {    
          curr = (DLLNode&lt;T&gt;)curr.getLink();      
      }
      if (curr == null) {
          return null;
      }
      else {
          return curr;
      }           
  }
  
  public int size() { 
      //Return number of elements in the list 
      return numElements;     
  }
  
  public boolean contains(T element) {
      //Does the list contain the given element?
      //Return true if so, false otherwise.
      if (find(element) == null) {
          return false;
      }
      else {
          return true;
      }
  }
  
  public boolean remove(T element) {
      //While the list is not empty, curr will move down. If the element can not
      //be found, then return false. Else remove the element.
      DLLNode&lt;T&gt; curr;
      curr = front;
      T currInfo = curr.getInfo();
      while(curr != null) {   
          curr = (DLLNode&lt;T&gt;)curr.getLink();      
      }
      if (find(element) == null) {
          return false;
      }
      else {
          if (curr == null) {
              curr = curr.getBack();
              curr = rear;
          }
          else if (curr == front) {
              curr = (DLLNode&lt;T&gt;)curr.getLink();
              curr = front;
          }
          else if (curr == rear) {
              curr = curr.getBack();
              curr = rear;
          }
          else {
  
          }
      return true;
      }
  }   
  
  public T get(T element) {
      //Return the info of the find method.
      if (find(element) == null) {
          return null;
      }
      else {
          return find(element).getInfo();
      }
  
  }
  
  //public String toString() {
  
  //}
  
  public void reset() {
      //Reset the iteration back to front
      curPosition = front;        
  }
  
  public T getNext() {
      //Return the info of the next element in the list
      DLLNode&lt;T&gt; curr;
      curr = front;
      //while (curr != null) {
          //curr = (DLLNode&lt;T&gt;)curr.getLink();
      //}
      if ((DLLNode&lt;T&gt;)curr.getLink() == null) {
          return null;
      }   
      else {
          curr = (DLLNode&lt;T&gt;)curr.getLink();
          return curr.getInfo();
      }       
  }
  
  public void resetBack() {
  
  }
  
  public T getPrevious() {
      //Return the previous element in the list
      DLLNode&lt;T&gt; curr;
      curr = front;
      if ((DLLNode&lt;T&gt;)curr.getLink() == null) {
          return null;
      }
      else if((DLLNode&lt;T&gt;)curr.getBack() == null) {
          return null;
      }
      else {
          curr = curr.getBack();
          return curr.getInfo();
      }
  }
  
  public void add(T element) {
      //PreCondition: Assume the element is NOT already in the list
      //AND that the list is not full!
      DLLNode&lt;T&gt; curr;                
      DLLNode&lt;T&gt;  newNode = (DLLNode&lt;T&gt;)element;
      curr = front;
      if (curr == null) {
          front = (DLLNode&lt;T&gt;)element;
      }
      else {
  
      }
  
    }
  }
  </code></pre>
  
  <p>This is the target main function eventually:</p>
  
  <pre><code>public static void main(String[] args){
  
   Double&lt;String&gt; d = new Double&lt;String&gt;();
   d.add("Hello");
   d.add("Arthur");
   d.add("Goodbye");
   d.add("Zoo");
   d.add("Computer Science");
   d.add("Mathematics");
   d.add("Testing");
  
   System.out.println(d);
  
   System.out.println( "Contains -Hello- " + d.contains("Hello"));
   System.out.println("Contains -Spring- " + d.contains("Spring"));
   System.out.println("size: " + d.size());
   d.resetBack();
   for (int i = 0; i &lt; d.size(); i++){
      String item = (String)d.getPrevious();
      System.out.println(item);
    } //good stopping point
   d.remove("Zoo");
   d.remove("Arthur");
   d.remove("Testing"); 
   System.out.println("size: " + d.size()); 
   System.out.println(d);
   d.remove("Goodbye");
   d.remove("Hello");
   System.out.println(d);
   d.remove ("Computer Science");
   d.remove("Mathematics");
   System.out.println(d);}
   }  
  </code></pre>