Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include #include #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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago