Question: in java The system will be implemented by a doubly circular linked list . The following classes should be created in this system. Student class
in java
The system will be implemented by a doubly circular linked list. The following classes should be created in this system.
Student class - contains two class fields and several methods:
name - The first and last names are in one string
id It is an int type data. It must be a unique number with 4 digits.
set/get methods
toString() method to allow displaying the content of an object. Organize the data properly for displaying.
Node class represents a node in the list. The data part contains one object of Student class. The link part contains two links, next and prev.
CircularList class represents a doubly linked circular list. It is defined as follow:
The class has two instance variables only:
cursor (Node type) - always point to the current element in the list
[Note: There are no first and last references in the list and you should not define another pointer such as current in any cases. The cursor is the current!]
size (int type) the number of elements in the list
The list is doubly linked and ordered.
The list has no head and no tail.
The cursor is null if the list is empty.
If the list contains only one element e1, the cursor refers to e1, and the next and the prev of e1 point to e1 itself.
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 (means they point to each other).
The operations (methods) of the class are:
boolean add (Node newNode) Request name and id from input and create a Node object (For practicing the test redundant, the id must be entered from the keyboard, not automatically created). This new node should be inserted in the list to keep the list in ascending order of the ID. The cursor will point to the new node after the insertion. Return true if the insert can be done successfully (no redundant), otherwise return false.
Node 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. The cursor should point to the node which is after the node to be removed.
Node 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 found node. The cursor should stay in the found node, or the last node compared.
String toString () for application class to display the contents of each node in the list (start from the cursor, no need to start from the lowest ID). Use toString() in the Student class.
[Hint:
Use a variable to remember the current size of the list. This var can be used to control the loop to traverse the list in different operations.
To insert a new record into the list, get the data (name and id) from user, create an object of Student, create a node with the student object, and then use add() method to insert the node (You may use search first to make sure the ID in the new record is unique).
In the search() and remove() methods, the return type must be a Node object which contains a Student object if the record can be found (or null if not found), not the Student object itself. This way, we allow the list to be easily changed to reuse for any other type of data.]
You may define other methods such as isEmpty( ) in the class.
Application class It implements the data management system to manage a Student list by using the circular list defined in step 3. This program displays a menu to allow the user to add, remove, search and display the data in the system, or quit from the system. When encounters any input errors, the system should continue to serve the user (indicate the problem and prompt for re-input) till the user select Quit. Use switch statement to process the operations in the menu. The system should display clear meaningful messages to user in prompts and error messages.
Write a good documentation to your program. Every class file must contain a header comments.
The classes included in this assignment: Student, Node, OrderedCircularList, ListApp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
