For my code I had to fill in the three methods of addFront, addRear, & addAfter. I keep getting an error however and I'm not sure why. Below is my errr and code
"LinkedUnorderedList.java:86: error: illegal start of type if(!found)) ^ LinkedUnorderedList.java:86: error: illegal start of type if(!found)) ^ LinkedUnorderedList.java:86: error: ')' expected if(!found)) ^ LinkedUnorderedList.java:86: error: ';' expected if(!found)) ^ LinkedUnorderedList.java:86: error: illegal start of type if(!found)) ^ LinkedUnorderedList.java:86: error: expected if(!found)) ^ LinkedUnorderedList.java:87: error: ';' expected throw new ElementNotFoundException("List"); ^ LinkedUnorderedList.java:87: error: invalid method declaration; return type required throw new ElementNotFoundException("List"); ^ LinkedUnorderedList.java:87: error: illegal start of type throw new ElementNotFoundException("List"); ^ LinkedUnorderedList.java:89: error: expected beforeCurent.setNext(temp); ^ LinkedUnorderedList.java:89: error: expected beforeCurent.setNext(temp); ^ LinkedUnorderedList.java:90: error: expected temp.setNext(current); ^ LinkedUnorderedList.java:90: error: expected temp.setNext(current); ^ LinkedUnorderedList.java:92: error: illegal start of type if(BeforeCurrent == tail) ^ LinkedUnorderedList.java:92: error: expected if(BeforeCurrent == tail) ^ LinkedUnorderedList.java:92: error: ';' expected if(BeforeCurrent == tail) ^ LinkedUnorderedList.java:92: error: illegal start of type if(BeforeCurrent == tail) ^ LinkedUnorderedList.java:95: error: expected count++; ^ LinkedUnorderedList.java:97: error: class, interface, or enum expected } "
/** * LinkedUnorderedList represents a singly linked implementation of an * unordered list. * * @author Lewis and Chase * @version 4.0 */ public class LinkedUnorderedList extends LinkedList implements UnorderedListADT { /** * Creates an empty list. */ public LinkedUnorderedList() { super(); }
/** * Adds the specified element to the front of this list. * * @param element the element to be added to the list */ public void addToFront(T element) { // To be completed as a Programming Project LinearNode temp = new LinearNode(element); if(size() == 0) head = tail = temp; else{ temp.setNext(head); head = temp; } count++; } /** * Adds the specified element to the rear of this list. * * @param element the element to be added to the list */ public void addToRear(T element) { // To be completed as a Programming Project LinearNode temp = new LinearNode(element); if(size() == 0) head = tail = temp; else{ tail.setNext(temp); tail = tail.getNext(); } count++; } /** * Adds the specified element to this list after the given target. * * @param element the element to be added to this list * @param target the target element to be added after * @throws ElementNotFoundException if the target is not found */ public void addAfter(T element, T target) { // To be completed as a Programming Project if(isEmpty()) throw new EmptyCollectionException("List"); LinearNode temp = new LinearNode(element); LinearNode current = head; LinearNode beforeCurrent = null; boolean found = false; while(!found && current != tail.getNext()) if(target.equals(current.getElement())) found = true; beforeCurrent = current; current = current.getNext(); } if(!found) throw new ElementNotFoundException("List"); beforeCurent.setNext(temp); temp.setNext(current); if(BeforeCurrent == tail) tail = temp; count++; } }
.