#include "booklist.h" #include #include using namespace std; void addBook(BookCollection & bc); void removeBook(BookCollection & bc); void findBook(const BookCollection & bc); void invalidCommand(); int main(){ BookCollection store; string response; for(;;){ cout << "Commands .. (add, find, remove, print, save, quit) " << endl; getline(cin,response); if(response == "quit"){ break; }else if(response == "add"){ addBook(store); }else if(response == "find"){ findBook(store); }else if(response == "remove"){ removeBook(store); }else if(response == "print"){ store.print(cout); }else if(response == "save"){ store.saveData(); }else{ cout << "Invalid Command " << endl; } } system("pause"); return 0; } void addBook(BookCollection & bc) { string title, author, isbn, price, response; cout << "Enter Title" << endl; getline(cin,title); cout << "Enter Author" << endl; getline(cin,author); cout << "Enter Isbn" << endl; getline(cin,isbn); cout << "Enter price" << endl; getline(cin,price); if(isValid(isbn)){ Book b(title,author,isbn,price); cout << "You are about to add this book (yes or no)" << endl << b << endl; getline(cin,response); if(response == "yes"){ bc.addBook(b); return; }else{ cout << "Book not added" << endl; return; } }else{ cout << "Isbn invalid, book not added " << endl; return; } } void removeBook(BookCollection & bc) { string isbn, response; cout << "Enter Isbn number" << endl; getline(cin ,isbn); cout << "This is the title you want to remove" << endl; cout << bc.findBook(isbn) << endl; cout << "remove it (yes or no)" << endl; getline(cin,response); if(response == "yes"){ bc.removeBook(isbn); }else{ cout << "Nothing removed" << endl; } return; } void findBook(const BookCollection & bc) { string isbn; cout << "Enter Isbn" << endl; getline(cin,isbn); cout << bc.findBook(isbn) << endl; return; }