Question: Java Implement the interface from Lab B (EntryWayListInterface). As a reminder, EntryWayListInterface allows the user to access to list elements only through the beginning and
Java
Implement the interface from Lab B (EntryWayListInterface). As a reminder, EntryWayListInterface allows the user to access to list elements only through the beginning and end of the list.
Your implementation can use either an expandable array or linked nodes- it is your choice. You can decide what instance variables are needed. You must implement every method from the interface. Make sure to account for special conditions such as empty lists and singleton lists. Note: your instance data variable should be either a) an array or b) one or more nodes. It should not be an AList or LList object or an ArrayList object.
Your implementation must compile and contain these implemented methods:
-insertHead
-insertTail
-deleteHead
-deleteTail
-display
-contains
-isEmpty
-isFull
Also create a driver program to test your implementation. The driver program will operate from the client perspective. Your driver program should:
-display an empty list
-add five entries to the list- some at the head and some at the tail
-display the list
-remove the first entry
-remove the last entry
-display the list
-test to see if elements are in the list (test one element that is in the list and one that is not)
-remove the last three elements in the list
-try to remove an element from the empty list
---------------------------------
EntryWayListInterface.java
public interface EntryWayListInterface
/**
* Places a new object at beginning of list
*
* @param newEntry the item to be added to the list
* @return true if the item was successfully added to the list; false otherwise
*/
boolean insertHead(T newEntry);
/**
* Places a new object at the end of the list
*
* @param newEntry the item to be added to the list
* @return true if the item was successfully added to the list; false otherwise
*/
boolean insertTail(T newEntry);
/**
* Deletes the object at the beginning of the list
*
* @return the object that has been deleted or null if the list is empty
*/
T deleteHead();
/**
* Delete the object at the end of the list
*
* @return the object that has been deleted or null if the list is empty
*/
T deleteTail();
/**
* Displays the contents of the list on the console, in order, one per line
*/
void display();
/**
* Searches the list for the given object and return its position in the
* list, or -1 if it's not found
*
* @param anEntry the object to search for in the list
* @return the position of the entry that was found or -1 if the object is not in the list not found
*/
int contains(T anEntry);
/**
* Checks to see if list is empty
*
* @return true if list is empty, false if list contains one or more
* objects
*/
boolean isEmpty();
/**
* Check if list is full
*
* @return true if list is full, false if list has space for more objects
*/
boolean isFull();
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
