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.
| |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
