I have to do a second assigment on doubly linked lists.
Create a class to implement a doubly linked list to store student records. Besides the basic operations, the class should include a sorting method that allow the user to sort the records in the list.
1. Create a doubly linked 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 number (string type) uniquely represent a student .
Defined the toString() method in this class to allow the list class to display the content of an object. Organize the data properly for displaying.
3. The doubly linked list class is defined as following: 1) The class name is RecordList. 2) The list contains ‘first’ and ‘last’ references as defined in our discussion. (You may refer the classes for the doubly linked list in the textbook.) 3) The list may contain insertFirst(), deleteFirst(), and any useful operations such as insertAfter(), etc. 4) The list class includes a method insertionSort() to sort the contents of the list by using the insertion sort methodology. [Note: the data should not be ordered by any inserting method. This assignment is for you to practice the implementation of the insertion sort algorithm in the doubly linked list.] 5) The list class must have the toString () for application class to display the content of all nodes in the list. This method should use toString() defined in the Student class.
- Write an application class to allow a user to:
1) Insert a Student record in the list
2) Short the list
3) Display the list (from the ‘first’ element)
4) 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: To insert a new record into the list, get the data (name and id) from user, create an object of Student, and then use the regular insert method (e.g. insertFirst() or insertLast() to insert.]
- Write a good documentation to your program.