Question: I need help implementing this code for my PROJECT please help. This is the requrment. : You are required to use the List interface from
I need help implementing this code for my PROJECT please help. This is the requrment. : You are required to use the List interface from the textbook. Additionally, you are required to use the Link class for doublylinked nodes which is different than the Link class for the practice assignments Furthermore, you are required to start with the textbook's implementation of a doublylinked list, the DLList class, but are not allowed to use a header node nor a trailer node so remove the code that creates them Name your class BasicDLList. Modify your BasicDLList class so that the results of each method are identical with those of the DLList class. Extend your MenuDriver class from Project by adding in code to create a BasicDLList object and calls its methods. Additionally, add in an option for V that calls the BasicDLList.toString method to list all of the strings in a commaseperated list. THis is my code I have now below, I need help with implemeting the link class,it is in the SCREENSHOT, I keep geeting errors about duplication of the class link when I submit it into an auto grade. Any changes made are welcome aslong as they follow the above requirments Thank you. class Link import java.util.NoSuchElementException;
public class BasicDLList implements List
private Link head; Pointer to first element
private Link tail; Pointer to last element
private Link curr; Access to current element
private int listSize; Size of list
public BasicDLList
clear;
public void clear
head tail curr null; No header or trailer
listSize ;
public boolean insertE it
if curr null List is empty
curr head tail new Linkit null, null;
else
Link tmp new Linkit curr.prev curr;
if currprev null
curr.prevsetNexttmp;
else
head tmp;
curr.setPrevtmp;
if curr head
head tmp;
listSize;
return true;
public boolean appendE it
if tail null List is empty
curr head tail new Linkit null, null;
else
Link tmp new Linkit tail, null;
tail.setNexttmp;
tail tmp;
listSize;
return true;
public E remove throws NoSuchElementException
if curr null
throw new NoSuchElementExceptionList is empty.";
E it curr.element;
if curr head
head head.next;
if head null
head.setPrevnull;
else if curr tail
tail tail.prev;
tail.setNextnull;
else
curr.prevsetNextcurrnext;
curr.nextsetPrevcurrprev;
if curr tail
curr null; Removed last element
else
curr curr.next;
listSize;
return it;
public void moveToStart
curr head;
public void moveToEnd
curr tail;
public void prev
if curr head
curr curr.prev;
public void next
if curr tail
curr curr.next;
public int length
return listSize;
public int currPos
Link temp head;
int i;
for i ; temp null && temp curr; i
temp temp.next;
return i;
public boolean moveToPosint pos
if pos pos listSize
return false;
curr head;
for int i ; i pos; i
curr curr.next;
return true;
public boolean isAtEnd
return curr tail;
public E getValue throws NoSuchElementException
if curr null
throw new NoSuchElementExceptionNo current element.";
return curr.element;
public boolean isEmpty
return listSize ;
@Override
public String toString
StringBuilder sb new StringBuilder;
sbappend;
Link temp head;
while temp null
sbappendtempelement;
if tempnext null
sbappend;
temp temp.next;
sbappend;
return sbtoString;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
