Question: (Java )Write a class definition for a Node class and a CircularList class that implements the CircularListInterface interface below. Note that the List methods involving

(Java)Write a class definition for a Node class and a CircularList class that implements the CircularListInterface interface below. Note that the List methods involving indices should count from the first element of the list as index 0. Throw an exception if the index is out-of-bounds.

You must use doubly linked nodes, including String data and Node references to previous and next Nodes, and the list must be a circular linked list.

public interface List{ public int size(); public boolean isEmpty(); public boolean contains(String item); public void add(String item); public boolean remove(String item); public void clear(); public String get(int index); public void set(int index, String element); public void add(int index, String item); public String remove(int index); public int indexOf(String item); // return -1 if item is not in the list }
public interface CircularListInterface extends List { /** moveFirst moves the pointer to the first element of the list up one. If myList contains [one,two,three,four], after myList.moveFirst(); it would then contain [two,three,four,one] */ public void moveFirst(); /** moveFirst(N) moves the pointer to the first element of the list up N. If myList contains [one,two,three,four], after myList.moveFirst(3); it would then contain [four,one,two,three] @param N the number of nodes to move forward */ public void moveFirst(int N); }

Write a driver program to test each of the methods in the class, including the List interface methods.

  • At the top of the file, a general description of the class, @author followed by your name, and @version followed by the date
  • Before each instance variable, between /** and */, a short description of the meaning of the instance variable (field).
  • At the top of each method (including constructors)
    • A general description of the method, with the name of the method between and
    • For each parameter, @param followed by the parameter name and a description of the parameter on the next line or two.
    • If an exception is thrown, @throws followed by the name of the exception.
    • For non-void functions, @return followed by what the method returns.

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!