Question
I need help. This is C++. I have no idea how to use vectors to fill this out. Requirements for each method are commented out
I need help. This is C++. I have no idea how to use vectors to fill this out. Requirements for each method are commented out above the method. I would greatly appreciate any help. I have to use vectors.
#include
#include "../includes_usr/library.h" #include "../includes_usr/datastructures.h" #include "../includes_usr/fileIO.h" using namespace std;
//NOTE: please ensure patron and book data are loaded from disk before calling the following //NOTE: also make sure you save patron and book data to disk any time you make a change to them //NOTE: for files where data is stored see constants.h BOOKFILE and PATRONFILE
/* * clear books and patrons containers * then reload them from disk */ void reloadAllData(){
}
/* checkout a book to a patron * first load books and patrons from disk * make sure patron enrolled (patronid is assigned to a patron in patrons container) * make sure book in collection (bookid is assigned to a book in books container) * * see if patron can check out any more books * if not return TOO_MANY_OUT patron has the MAX_BOOKS_ALLOWED_OUT * * if so then check the book out to the patron, set the following fields for the book in the * books container * book.loaned_to_patron_id = patronid; * book.state = OUT; * * Finally save the contents of the books and patrons containers to disk * * returns SUCCESS checkout worked * PATRON_NOT_ENROLLED * BOOK_NOT_IN_COLLECTION * TOO_MANY_OUT patron has the max number of books allowed checked out */ int checkout(int bookid, int patronid){ return SUCCESS; }
/* check a book back in * first load books and patrons from disk * make sure book in collection (bookid is assigned to a book in books container) * * if so find the the patron the book is checked out to and decrement his/hers number_books_checked_out * then check the book back in by marking the book.loaned_to_patron_id = NO_ONE and the book.state = IN; * Finally save the contents of the books and patrons containers to disk * * returns SUCCESS checkout worked * BOOK_NOT_IN_COLLECTION */ int checkin(int bookid){ return SUCCESS; }
/* * enroll a patron, duplicate names are fine as patrons are uniquely identified by their patronid * first load books and patrons from disk * create a patron object, initialize its fields as appropriate, assign him/her the nextPatronID * then push the patron onto the patrons container * save all changes to the patrons container to disk * return * the patron_id of the person added */ int enroll(std::string &name){ return 0; }
/* * the number of books in the books container * (ie. if 3 books returns 3) * */ int numbBooks(){ return 0; }
/* * the number of patrons in the patrons container * (ie. if 3 patrons returns 3) */ int numbPatrons(){ return 0; }
/*the number of books patron has checked out * *returns a positive number indicating how many books are checked out * or PATRON_NOT_ENROLLED */ int howmanybooksdoesPatronHaveCheckedOut(int patronid){ return 0; }
/* search through patrons container to see if patronid is there * if so returns the name associated with patronid in the variable name * * returns SUCCESS found it and name in name * PATRON_NOT_ENROLLED no patron with this patronid */ int whatIsPatronName(std::string &name,int patronid){ return SUCCESS; }
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