int main() { try { Library::Library lib; lib.add_book("89-89-09-sq2","Three body","ci",Chrono::today(),Book::Book::fiction); lib.add_patron("qi", "123"); lib.loan_book(lib.Patrons()[0], lib.Books()[0]); } catch (...) { cout << "error" << endl; } return 0; }
//Creates a simple interface that allows for the execution of multiple functions of book, patron, and library //Uses a loop to allow for consecutive operations until user quits int main(){ try{ //Only uses one library, called lib Library::Library lib; cout << "Choose Operation" << endl << "1: Create Patron" << endl << "2: Create Book" << endl << "3: Set Patron Fees" << endl << "4: Print Book Details" << endl << "5: Print Patron Details" << endl << "6: Print list of Patrons with Fees" << endl << "7: Check out a Book" << endl << "8: Print all Transactions" << endl << "Q: Quit"; //Different chars lead to different operations; loops until user inputs a char that is not 1 through 8 bool finished = false; while (!finished){ char ch; cout << endl << '>'; cin >> ch; //Clears enter from buffer so getline isn't skipped cin.ignore(numeric_limits<streamsize>::max(), '\n'); //Queries book info and adds book to library if (ch == '1') { string name, cardnumber; double fees; cout << endl << "Enter name: "; getline(cin,name); cout << "Enter card number: "; cin >> cardnumber; cout << "Enter fees: "; cin >> fees; Patron::Patron pp(name, cardnumber, fees); lib.add_patron(pp); } //Queries patron info to add to library else if (ch == '2') { string ISBN, title, author; int g; Date::Date dd; cout << endl << "Enter title: "; getline(cin,title); cout << "Enter author: "; getline(cin,author); cout << "Enter ISBN: "; cin >> ISBN; cout << "Enter genre (1 = fiction, 2 = nonfiction, 3 = periodical, " << "4 = biography, 5 = children): "; cin >> g; cout << "Enter copyright date: "; cin >> dd; Book::Book bb(ISBN, title, author, Book::Book::Genre(g), dd); lib.add_book(bb); }