Question
**********main.cpp********** Library myLib; //Read the dataset file and loads myLib list void loadDataset(string fileName){ ifstream inFile; inFile.open(fileName.c_str()); string line; while(getline(inFile,line)){ int ind1 = line.find(#); int
**********main.cpp**********
Library myLib;
//Read the dataset file and loads myLib list
void loadDataset(string fileName){
ifstream inFile;
inFile.open(fileName.c_str());
string line;
while(getline(inFile,line)){
int ind1 = line.find("#");
int ind2 = line.find("#",ind1+1);
string title = line.substr(0,ind1);
string author = line.substr(ind1+1, ind2-ind1-1);
string ISBN = line.substr(ind2+1);
//Here we add the new book. Please make sure your function name matches
myLib.addBook(title,author,ISBN);
}
}
//Just for convenience...
void continueMessage(string message){
cout
cout
}
int main() {
string fileName = "dataset.txt";
loadDataset(fileName);
continueMessage("Dataset file is loaded to the program!");
//---------------------------------------------------------------------------
myLib.print();
continueMessage("All books in the library are listed!");
//---------------------------------------------------------------------------
string title = "Total Recall: How the E-Memory Revolution Will Change Everything";
string author = "C. Gordon Bell";
string ISBN = "592968760-9";
myLib.addBook(title,author,ISBN);
continueMessage("New book, with " + ISBN + " ISBN is added to the library.");
//---------------------------------------------------------------------------
myLib.print(title[0]); string s(1, title[0]);
continueMessage("The books, whose title starts with "+s+", are listed.");
//---------------------------------------------------------------------------
author = "W. Richard Stevens";
myLib.print(author);
continueMessage("The books, whose author is "+author+", are listed.");
//---------------------------------------------------------------------------
myLib.removeBook(ISBN);
continueMessage("The book, with " + ISBN + " ISBN is removed from the library.");
//---------------------------------------------------------------------------
Textbook tb = myLib.at(5);
cout
//---------------------------------------------------------------------------
int size = myLib.getSize();
cout
return 0;
}
**********dataset.txt**********
Introduction to Algorithms#Thomas H. Cormen#878134263-2 Structure and Interpretation of Computer Programs#Harold Abelson#336190405-6 The C Programming Language#Brian W. Kernighan#699022731-1 The Pragmatic Programmer: From Journeyman to Master#Andy Hunt#888099490-5 The Art of Computer Programming, Volumes 1-3 Boxed Set#Donald Ervin Knuth#625268126-1 Design Patterns: Elements of Reusable Object-Oriented Software#Erich Gamma#604854500-2 Introduction to the Theory of Computation#Michael Sipser#615228728-6 Code: The Hidden Language of Computer Hardware and Software#Charles Petzold#822491420-8 The Mythical Man-Month: Essays on Software Engineering#Frederick P. Brooks Jr.#987411743-5 Artificial Intelligence: A Modern Approach#Stuart Russell#704058716-5 Code Complete#Steve McConnell#465609758-6 The Protocols (TCP/IP Illustrated, Volume 1)#W. Richard Stevens#126456048-6 Algorithms#Robert Sedgewick#873746894-4 Advanced Programming in the UNIX Environment#W. Richard Stevens#598255768-4 A Discipline of Programming#Edsger W. Dijkstra#412861075-5 Introduction to Automata Theory, Languages, and Computation#John E. Hopcroft#952883775-1 Compilers: Principles, Techniques, and Tools#Alfred V. Aho#557104773-9 Joel on Software#Joel Spolsky#394368902-6 Learn You a Haskell for Great Good!: A Beginner's Guide#Miran Lipova a#260995077-2 The Society of Mind#Marvin Minsky#539224508-0
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 wil create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Type Attribute String String String Textbook* 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: 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 wil create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Type Attribute String String String Textbook* 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
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