Commit 76f2f0b1 authored by michael lundquist's avatar michael lundquist
Browse files

Fixing a bug in the doublyLinkedList.

parent 35c71586
Pipeline #3985 passed with stage
in 1 minute and 18 seconds
......@@ -45,12 +45,12 @@ public class DoublyLinkedList {
}
public boolean remove(String query){
public boolean remove(Scientist query){
boolean flag=false;
if(size==0) return flag;
DoublyLNode current = head;
do{
if(current.getData().equals(query)){
if(current.getData().compareTo(query) == 0){
//remove current
DoublyLNode prev = current.getPrevious();
DoublyLNode next =current.getNext();
......
......@@ -4,13 +4,13 @@ public class Test_DoublyLinkedList {
public static void main(String[] args){
DoublyLinkedList dlist = new DoublyLinkedList();
dlist.addToHead(new DoublyLNode("1", null, null));
dlist.addToHead(new DoublyLNode("2", null, null));
dlist.addToHead(new DoublyLNode("3", null, null));
dlist.addToHead(new DoublyLNode("4", null, null));
dlist.addToHead(new DoublyLNode(new Scientist("A"), null, null));
dlist.addToHead(new DoublyLNode(new Scientist("B"), null, null));
dlist.addToHead(new DoublyLNode(new Scientist("D"), null, null));
dlist.addToHead(new DoublyLNode(new Scientist("J"), null, null));
System.out.println(dlist.display());
dlist.remove("3");
dlist.remove(new Scientist("B"));
System.out.println(dlist.display());
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment