Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part I: Create a doubly linked circular list class named LinkedItemList that implements the following interface: /** * An ordered list of items. */ public

Part I:

Create a doubly linked circular list class named LinkedItemList that implements the following interface:

/**

* An ordered list of items.

*/

public interface ItemList {

/**

* Append an item to the end of the list

*

* @param item item to be appended

*/

public void append(E item);

/**

* Insert an item at a specified index position

*

* @param item item to be inserted

* @param index index position where to insert the item

* @throw IndexOutOfBoundsException if index is < 0 or > no of items

*/

public void insert(E item, int index);

/**

* Return an item at a specified index

*

* @param index index of the item to return

* @return the item at the specified index

* @throw IndexOutOfBoundsException if index is < 0 or >= no of items

*/

public E get(int index);

/**

* Remove an item at a specified index

*

* @param index index of the item to be removed

* @return the removed item

* @throw IndexOutOfBoundsException if index is < 0 or >= no of items

*/

public E removeAtIndex (int index);

/**

* Return the number of items currently in the list

*

* @return the number of items in the list

*/

public int size();

/**

* Determine if the list is empty

*

* @return true if the list is empty, otherwise false

*/

public boolean isEmpty();

/**

* Clear the list. The list becomes empty

*

*/

public void clear();

}

You will need the appropriate constructors. In addition, you may also implement other methods that may be useful for the assignment (where possible define code in just one place).

Part II:

Write JUnit test program to thoroughly test all of the methods of your LinkedItemList class

Additional Requirements:

The LinkedItemList must be implemented as a doubly linked circular list with a dummy node in place of a first node and last node reference variables.

Provide a fast implementation for append(), e.g., does not need to walk the list to get to the end.

Define and use a private method appendAfter(Node node, E item) which adds a Node to the linked list for the item. Call appendAfter from the append and insert methods. The append and insert methods must not directly create a node.

Define and use a private method removeNode(Node node) which removes a Node from the linked list. Call removeNode from the removeAtIndex method. The removeAtIndex method must not directly remove a node.

Define and use a private method getNode(int index) which returns a node at a given index position. Use getNode in the get, removeAtIndex, and insert methods

Provide a fast implementation for size(), e.g., does not need to walk the list to count the number of items

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

e. What are notable achievements of the group?

Answered: 1 week ago