1. Create a doubly linked circular list in Java. Each element in the list contains a data which is an object of a Student class and two links, next and previous.
2. The Student class contains two class fields only:
• name - The first and last names are in one string
• id – It is a string number generated when insert the object into the list. It must be a unique number.
3. The circular list class is defined as following:
1) The class name is CircularList.
2) The class has two class fields only:
• cursor (Link) - always point to the current element in the list
[Note: There is no ‘first’ in the list and don’t define another pointer ‘current’. The ‘cursor’ is the ‘current’.]
• size (int) – the number of elements in the list
3) The list is doubly linked and unordered.
4) The list has no head and no tail.
5) The cursor is null if the list is empty.
6) If the list contains only one element e1, the cursor refers to e1, and the next and previous of e1 point to e1 itself.
7) If the list contains two elements e1 and e2, the next and previous of e1 point to e2, and the next and previous of e2 point to e1.
8) The operations (methods) of the class are:
• void add (Student s) – add a new element after the node pointing by cursor
• Link remove (int key) – remove the element in which the id of the object matches the given key. The method returns null if the key is not found; otherwise it returns the node of the removed element. After this operation, the ‘current’ should stay at the node before or after the deleted node, or back to the original node for ‘not found’ case.
• Link search (int key) – search an element by the given key (an id). The method returns null if the key is not found; otherwise it returns the node of the element. After this operation, the ‘current’ should point to the ‘found’ node, or back to the original node for ‘not found’ case.
Note: for ‘remove’ and ‘search’, don’t use extra pointer to go through the list. The ‘current’ is for doing the works.
9) You may define other methods like isEmpty( ) and toString( ) in the class.
4. Write a data management system to manage a Student list by using the circular list created in step 1. This program displays a menu list to allow the user to add, remove, search and display the data in the system, or quit from the system. The system should continue to serve the user till the user select to quit. The system should prompt the user properly for any input and operation results.
[Hint: For inserting a new record into the list, get the data (name and id) from user, create an object of Student, and then use add() method to insert.