From: stephey <stephey>
Date: Tue, 29 Mar 2011 06:52:04 +0000 (+0000)
Subject: Changed LinkedList to return a boolean instead of crashing when an object isn't found... 
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=34b3909856be9ef0aa85935840ef5443b7bf18d4;p=IRC.git

Changed LinkedList to return a boolean instead of crashing when an object isn't found in the remove method.
---

diff --git a/Robust/src/ClassLibrary/LinkedList.java b/Robust/src/ClassLibrary/LinkedList.java
index e2af0104..3fe96141 100644
--- a/Robust/src/ClassLibrary/LinkedList.java
+++ b/Robust/src/ClassLibrary/LinkedList.java
@@ -151,27 +151,29 @@ public class LinkedList {
     return o;
   }
 
-  public void remove(Object o) {
+  public boolean remove(Object o) {
     if( head == null ) {
-      System.out.println("LinkedList: illegal remove( Object o )");
-      System.exit(-1);
+//      System.out.println("LinkedList: illegal remove( Object o )");
+//      System.exit(-1);
+      return false;
     }
     LinkedListElement e = head;
-    while( e != null ) {
-      if( e.element == o ) {
-	if( e.prev != null ) {
-	  e.prev.next = e.next;
-	}
-	if( e.next != null ) {
-	  e.next.prev = e.prev;
-	}
-	size--;
-	return;
+    while (e != null) {
+      if (e.element == o) {
+        if (e.prev != null) {
+          e.prev.next = e.next;
+        }
+        if (e.next != null) {
+          e.next.prev = e.prev;
+        }
+        size--;
+        return true;
       }
       e = e.next;
     }
-    System.out.println("LinkedList: illegal remove( Object o ), "+o+" not found");
-    System.exit(-1);
+//    System.out.println("LinkedList: illegal remove( Object o ), "+o+" not found");
+//    System.exit(-1);
+    return false;
   }
 
   public Object pop() {