Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please answer all questions. The required file: EntryWayListInterface has been added below in bold. 1. Implement the interface (EntryWayListInterface). As a reminder, EntryWayListInterface allows the

Please answer all questions. The required file: EntryWayListInterface has been added below in bold.

1. Implement the interface (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. (Submit only one implementation.) 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 node objects. It should notbe an AList, LList, ArrayList, or other kind of object.

Please use the interface file provided here:

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();

}

Your implementation must:

compile.

contain these implemented methods:

insertHead

insertTail

deleteHead

deleteTail

display

contains

isEmpty

isFull

2. Create a driver program to test your implementation. The driver program will operate from the client perspective. Your driver program should do each of the following in this order without crashing:

display an empty list

add six entries to the list- some at the head and some at the tail

display the list

remove the last entry

remove the first 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 four elements in the list (using any of the remove methods)

try to remove an element from the empty list

3. Write a second, additional class to implement EntryWayListInterface. (You still must complete the first class, above!)

Instead of using an array or linked nodes, use either an AList or LList object as your instance data variable. In this way, you are using an existing data type (AList or LList) to implement a new data type (EntryWayListInterface). Inside the methods of this class, invoke methods on the AList or LList object to accomplish the task.

Note: your methods might look very simple... this does not mean they are wrong.

Note: if you run your test program using this class to initialize your EntryWayListInterface object, the program should run exactly the same as it did above! In other words, you should only have to change one line (the line that initializes the EntryWayListInterface object) and the rest of the code should run the same.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions