Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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++; } }

.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions