Question: The BilinkedList 2 8 0 classes in lib 2 8 0 - asn 1 are incomplete. There are missing method bodies in each class. Each

The BilinkedList280 classes in lib280-asn1 are incomplete. There are missing method bodies in each class. Each missing method body is tagged with a // TODO comment. Write code to implement each of these unfinished method. Implementation Notes the javadoc headers for each method explain what each method is supposed to do3. Many of the methods you must implement override methods of the LinkedList280 superclass. Add your code right into the existing files within the lib280-asn1 module.When implementing the methods, consider carefully any special cases that might cause need to update
the cursor position, or ensure that it remains in a valid state.You are not permitted to modify any existing code in the .java files given. You may only fill in the missing method bodies.
This is the Bilinkedlist280 class starter file please add all the missing methods and answer the question above
package lib280.list;
import lib280.base.BilinearIterator280;
import lib280.base.CursorPosition280;
import lib280.base.Pair280;
import lib280.exception.*;
/** This list class incorporates the functions of an iterated
dictionary such as has, obtain, search, goFirst, goForth,
deleteItem, etc. It also has the capabilities to iterate backwards
in the list, goLast and goBack. */
public class BilinkedList280 extends LinkedList280 implements BilinearIterator280
{
/* Note that because firstRemainder() and remainder() should not cut links of the original list,
the previous node reference of firstNode is not always correct.
Also, the instance variable prev is generally kept up to date, but may not always be correct.
Use previousNode() instead! */
/** Construct an empty list.
Analysis: Time = O(1)*/
public BilinkedList280()
{
super();
}
/**
* Create a BilinkedNode280 this Bilinked list. This routine should be
* overridden for classes that extend this class that need a specialized node.
* @param item - element to store in the new node
* @return a new node containing item
*/
protected BilinkedNode280 createNewNode(I item)
{
// TODO
return null; // This line is present only to prevent a compile error. You should remove it before
// completing this method.
}
/**
* Insert element at the beginning of the list
* @param x item to be inserted at the beginning of the list
*/
public void insertFirst(I x)
{
// TODO
}
/**
* Insert element at the beginning of the list
* @param x item to be inserted at the beginning of the list
*/
public void insert(I x)
{
this.insertFirst(x);
}
/**
* Insert an item before the current position.
* @param x - The item to be inserted.
*/
public void insertBefore(I x) throws InvalidState280Exception {
if( this.before()) throw new InvalidState280Exception("Cannot insertBefore() when the cursor is already before the first element.");
// If the item goes at the beginning or the end, handle those special cases.
if( this.head == position ){
insertFirst(x); // special case - inserting before first element
}
else if( this.after()){
insertLast(x); // special case - inserting at the end
}
else {
// Otherwise, insert the node between the current position and the previous position.
BilinkedNode280 newNode = createNewNode(x);
newNode.setNextNode(position);
newNode.setPreviousNode((BilinkedNode280)this.prevPosition);
prevPosition.setNextNode(newNode);
((BilinkedNode280)this.position).setPreviousNode(newNode);
// since position didn't change, but we changed it's predecessor, prevPosition needs to be updated to be the new previous node.
prevPosition = newNode;
}
}
/** Insert x before the current position and make it current item.
Analysis: Time = O(1)
@param x item to be inserted before the current position */
public void insertPriorGo(I x)
{
this.insertBefore(x);
this.goBack();
}
/** Insert x after the current item.
Analysis: Time = O(1)
@param x item to be inserted after the current position */
public void insertNext(I x)
{
if (isEmpty()|| before())
insertFirst(x);
else if (this.position==lastNode())
insertLast(x);
else if (after())// if after then have to deal with previous node
{
insertLast(x);
this.position = this.prevPosition.nextNode();
}
else // in the list, so create a node and set the pointers to the new node
{
BilinkedNode280 temp = createNewNode(x);
temp.setNextNode(this.position.nextNode());
temp.setPreviousNode((BilinkedNode280)this.position);
((BilinkedNode280) this.position.nextNode()).setPreviousNode(temp);
this.position.setNextNode(temp);
}
}
/**
* Insert a new element at the end of the list
* @param x item to be inserted at the end of the list
*/
public void insertLast(I x)
{
// TODO
}
/**

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!