Uploaded by Hoàng Nguyễn Duy

LINKED LIST PROBLEMS

advertisement
LINKED LIST PROBLEMS
Using Linked List data structure for implementing a Book Management in Java
language. Information about book includes:
- bcode (string): the code of the book
- title (string): the book title
- price (double): the price of book
YOUR TASK: Build MyList class as a linked list of Book objects, with the
following methods:
1. void add(String xCode, String xTitle, double xPrice) – add a new book to the
end of the list.
2. void traverse() - Traverse the linked list in one line with the format of each book:
(bcode, title, price)
3. void sortName() – sort the list in the alphabetical order of the book name.
4. void delete() – delete the first book in the list.
5. Node getNth(int k) – return the k-th node in the list (head is the 0-th node).
6. int count() – return the number of the books in the list.
7. int deleteAll(String xTitle) – delete all the books having title as xTitle, return the
number of the deleting books.
Download