Question
Modify the booklist program (from the lecture notes) by adding delet and insert operations into the BookList class. The insert method should be based on
Modify the booklist program (from the lecture notes) by adding delet and insert operations into the BookList class. The insert method should be based on a compareTo() method in the Book class that determines if one book title comes before another alphabetically. The insert method will maintain the BookList in alphabetical order. Exercise various insertion and deletion operations, using the code below for your main program: //lib.cpp #include pch.h #include using namespace std; #include "BookList.h" int main(int argc, char* argv[]) { //-------------------------------------------------------------- // Creates a BookList object, adds several books to the list, // then prints them. //-------------------------------------------------------------- char list[LIST_LEN]; BookList *books = new BookList(); books->insert (new Book("F Title") ); books->insert (new Book("D Title")); books->insert (new Book("G Title")); books->insert (new Book("A Title")); books->insert (new Book("E Title")); books->insert (new Book("H Title")); cout << "After inserts: ; cout << books->getBookList(list) << endl;; books->delet (new Book("A Title")); books->delet (new Book("H Title")); books->delet (new Book("G Title")); books->delet (new Book("E Title")); cout << "After deletes: "; cout << books->getBookList(list) << endl;; books->insert (new Book("A Title")); books->insert (new Book("E Title")); books->insert (new Book("H Title")); books->insert (new Book("G Title")); cout << "After 2nd inserts: ; cout << books->getBookList(list) << endl;; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started