C++ Data structures and algorithm Library.h and Library.cpp 1 #include #include #include Library . h

C++ Data structures and algorithm Library.h and Library.cpp
1 #include #include #include Library . h 2 3 4 5 using namespa” aria-describedby=”ddv”> In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a “next” pointer. Textbook Type String String String Textbook Attribute title author ISBN next Library class should have a head node as an attribute to keep the list of the books. Also, following member functions should be implemented in this class: Library Type Textbook* Attribute head Return Type Function constructor void addBook(string title, string author, string ISBN) removeBook(string ISBN) print() print(char startingLetter) print(string author) at(int index) getSize() isEmpty() void void void void Textbook int bool addBook(): Adds a new book to the list. The new book is placed based on the ALPHABETICAL ORDER of the titles. You shouldn't add the textbook directly to the end or front of the list. The new book has to be inserted to the correct position. For example, if you have following three books: The C The Society of Mind Algorithms Programming Language A new book, “Applied Cryptography” will be placed in alphabetical order between the first and second book removeBook(): This functions willl remove a book using the given ISBN number. If the given ISBN number is not in the list, it will give an error. print(): Print all books in (alphabetical) order. Title, author, and the ISBN should be printed for each book. print(char startingLetter): Prints all books whose title starts with the input character, “startingLetter”. print(string author): Prints all books of an author. print(): Print all books in (alphabetical) order. Title, author, and the ISBN should be printed for each book. print(char startingLetter): Prints all books whose title starts with the input character, “startingLetter” print(string author): Prints all books of an author. at(int index): Returns the book at given index getSize(): returns the number of books in the list isEmpty(): returns true if list is empty, returns false otherwise. The main program (main.cpp) is provided for you. So you will only implement the Textbook and library classes. I expect you to have 2 files: Library.h and Library.cpp Textbook class definition will be in the Library.h file. main.cpp includes all necessary functions to read the dataset file (dataset.txt). Also, several test cases are prepared for you to see whether your code is running or not. You do not need to change any code in the main.cpp file. Whenever you include your library class and main cpp to your project, they must run properly together. Additional Resources: Additional Resources: In addition,I have provided an integer single linked list C++ class to help you to study for linked lists. If you study that code, you can see the following functions: void pushBack (int newvalue) void insertAt (int newValue, int index) int at (int index) int removeAt (int index) void print ( This code is given you for a reference not to use it in this assignment. There are some functions in that class that you don't need or there are some which requires some modifications. Start here main.cpp x #include 1 #include #include #include “Library . h” 2 3 4 5 using namespace std Library myLib /Read the dataset file and loads myLib list 10 Evoid loadDataset (string fileName) 11 12 ifstream inFile; inFile.open (fileName.c str ()); 13 14 15 string line: while (getline (inFile, line) ) 16 17 1ine . find (“#”) line. find (“#”, ind1+1) ; 18 int indl 19 int ind2 I 20 string title line.substr (0, indl); string author line.substr (indl+1, ind2-indl-1) ; string ISBNline.substr (ind2+1); 21 22 23 24 //Here we add the new book. Please make sure your function name matches 25 26 myLib.addBook (title, author, ISBN) ; 27 ogs & others x Cccc X Search results Buld log Build messages x CppCheck/Vera++ x CppCheck/Vera++ X File Message Line n 300 eels C tart here main.cpp x Ly 28 29 11Just for cohvenience. 30 Evoid continueMe ssage (string message) { 31 cout Start here main.cpp x 51 continueMessage (“New book, with 52 +ISBN + “ISBN is added to the library.”): 53 54 myLib.print (title [0]): string (1, title[0]); continueMessage (“The books, whose title starts with “+s+”, are listed.”); 55 56 57 58 author “. Richard Stevens” 59 60 myLib.print (author); continueMessage (“The books, whose author is “+author+”, are 1isted.”); 11– 61 62 63 myLib.remove Book (ISBN) continueMessage (“The book, with 64 65 + ISBN ISBN is removed from the library.”) 66 67 Textbook tb myLib.at (5) coat

 

Looking for a Similar Assignment? Let us take care of your classwork while you enjoy your free time! All papers are written from scratch and are 100% Original. Try us today! Use Code SAVE15 for 15% discount