Question
Using a doubly linked list as the underlying data structure, implement a list ADT that implements the ListInterface.java found in the ProgProjTwo Eclipse project starting
Using a doubly linked list as the underlying data structure, implement a list ADT that implements the ListInterface.java found in the ProgProjTwo Eclipse project starting point for this assignment.
In addition to the forward iterator defined by resetIterator( ) and getNextItem( ) in ListInterface.java, implement a backwards iterator by providing resetBackIterator( ) and getPreviousItem( ) methods.
As noted in the syllabus addendum, you are encouraged to develop a find( ) helper method that can support various list ADT operations.
A DLLNode class for your use can also be found in ProgProjTwo. You may use a list node object of your own design, but the implementing data structure for this assignment must be a doubly linked list class that you develop.
Develop a test driver for the list implementation that exercises each of the ADT operations and the backwards iterator. The test driver must be consistent with your test plan.
In addition to submitting all of your source code in a single Eclipse project, and overall description of the project, a test plan and a test report, as described in the Programming Projects General requirements, are required.
Included code below
package dllNode;
public class DLLNode
private E info;
private DLLNode
private DLLNode
public DLLNode(E info) {
this.info = info;
next = null;
prev = null;
}
public void setInfo(E info) {
this.info = info;
}
public E getInfo() {
return info;
}
public void setNext(DLLNode
this.next = reference;
}
public DLLNode
return next;
}
public void setPrev(DLLNode
this.prev = reference;
}
public DLLNode
return prev;
}
}
__________________________________________________________________________________________________
package listInterface;
public interface ListInterface
int size(); // return the number of elements on this list
boolean isEmpty();
void add(E element);
boolean remove (E element);
// remove an element e from this list such that e.equals(element) and return true;
// if no such element exists, return false
boolean contains (E element);
// return true if this list contains an element e such that e.equals(element);
// otherwise, return false
E get(E element);
// return an element e from this list such that e.equals(element);
// if no such element exists, return null
String toString();
// returns an appropriately formatted string that represents this list.
void resetIterator();
// set the current position for the getNext() iterator to the first element on the list
E getNextItem();
// Preconditions: The list is not empty
// The resetIterator() method has been invoked
// The list has not been modified since the most recent resetIterator() call
//
// return the element at the current position on this list;
// update the current pointer to point to the next element on the list
// note: if the element returned is the last item on the list,
// set the value of the current position to the first element on the list
}
__________________________________________________________________________________________________
package project2;
import listInterface.ListInterface;
import dllNode.DLLNode;
public class DoublyLinkedList
protected DLLNode
protected DLLNode
// other instance variables are needed
public DoublyLinkedList() {
head = null;
tail = null;
// you may want to have more stuff here
// depending upon your implementation
}
@Override
public void add(E element) {
}
// the find makes life easier, but is not strictly required
protected void find(E target) {
}
@Override
public int size() {
return 0;
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public boolean contains (E element) {
return true;
}
@Override
public boolean remove (E element) {
return true;
}
@Override
public E get(E element) {
return null;
}
@Override
public String toString()
// Returns a nicely formatted string that represents this list.
{
return null;
}
@Override
public void resetIterator() {
}
@Override
public E getNextItem() {
return null;
}
public void resetBackIterator() {
}
public E getPreviousItem() {
return null;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started