A readinglist is a doubly linked list in which each element of the list is a book. So, you must make sure that Books are linked with the previous prev and next element. A readinglist is unsorted by default or sorted (according to title) in different context. Please pay attention to the task description below. Refer to the relevance classes for more detail information. Implement the add_book_sorted method of the ReadingList class. Assume the readinglist is sorted by title, the add_book_sorted method takes an argument new_book (a book object), it adds the new_book to the readinglist such that the readinglist remain sorted by title. For example, if the readinglist contain the following 3 books: Title: Artificial Intelligence Applications Author: Cassie Ng Published Year: 2000 Title: Python 3 Author: Jack Chan Published Year: 2016 Title: Zoo Author: Cassie Chun Published Year: 2000 If we add another book (titled "Chinese History"; author "Qin Yuan"; and published year 1989) to the readinglist using the add_book_sorted method, the resulting readinglist would contain the following books: Title: Artificial Intelligence Applications Author: Cassie Ng Published Year: 2000 Title: Chinese History Author: Qin Yuan Published Year: 1989 Title: Python 3 Author: Jack Chan Published Year: 2016 Title: Zoo Author: Cassie Chun Published Year: 2000 Note that you method will also be able to add a new book to an empty readinglist.
A readinglist is a doubly linked list in which each element of the list is a book. So, you must make sure that Books are linked with the previous prev and next element.
A readinglist is unsorted by default or sorted (according to title) in different context. Please pay attention to the task description below. Refer to the relevance classes for more detail information.
Implement the add_book_sorted method of the ReadingList class.
Assume the readinglist is sorted by title, the add_book_sorted method takes an argument new_book (a book object), it adds the new_book to the readinglist such that the readinglist remain sorted by title.
For example, if the readinglist contain the following 3 books:
Title:
If we add another book (titled "Chinese History"; author "Qin Yuan"; and published year 1989) to the readinglist using the add_book_sorted method, the resulting readinglist would contain the following books:
Title: Artificial Intelligence Applications Author: Cassie Ng Published Year: 2000 Title: Chinese History Author: Qin Yuan Published Year: 1989 Title: Python 3 Author: Jack Chan Published Year: 2016 Title: Zoo Author: Cassie Chun Published Year: 2000
Note that you method will also be able to add a new book to an empty readinglist.
Step by step
Solved in 2 steps with 3 images