Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

*holdings - a list of Books the Library has *members - a list of Patrons the Lib

ID: 644421 • Letter: #

Question

*holdings - a list of Books the Library has
*members - a list of Patrons the Library has
*currentDate - stores the current date represented as an integer number of "days" since the Library object was created
*a constructor that initializes the currentDate to zero
*addBook - prompts the user for book info (including the ID, which can be any arbitrary string) and uses it to create a Book, which is added to holdings
*addMember - prompts the user for patron info (including the ID, which can be any arbitrary string) and uses it to create a Patron, which is added to members
*checkOutBook
-if the specified Book or Patron are not in the Library (an ID doesn't match an object in the Library), print out that message and return to the menu
-if a Book is already checked out, print out that message and return to the menu
-if a Book is on hold by another Patron, print out that message and return to the menu
-otherwise update the Book's checkedOutBy, dateCheckedOut and Location; if the Book was on hold for this Patron, update requestedBy; update the Patron's list; print out that Book title has been checked out to Patron name
*returnBook
-if the specified Book is not in the Library, print out that message and return to the menu
-if the Book is not checked out, print out that message and return to the menu
-update the Patron's list; update the Book's location depending on whether another Patron has requested it; update the Book's checkedOutBy; print out that Book titlehas been returned

*requestBook
-if the specified Book or Patron are not in the Library, print out that message and return to the menu
-if the Book is already requested by another Patron, print out that message and return to the menu
-If the Book is currently checked out by the same Patron who is trying to request it, print out that message and return to the menu
-update the Book's requestedBy; if the Book is on the shelf, update its location to on hold; print that Book title is on request for Patron name
*
payFine
-if the specified Patron is not in the Library, print out that message and return to the menu
-use amendFine to update the Patron's fine; print out that the fines for Patron nameare now Patron fineAmount
*
incrementCurrentDate
-increment current date; increase each Patron's fines by 10 cents for each overdue Book they have checked out (using amendFine)
*viewPatronInfo
-if the specified Patron is not in the Library, print out that message and return to the menu
-print the Patron's ID, name, the titles of any checked out Books, and their current fines
*viewBookInfo
-if the specified Book is not in the Library, print out that message and return to the menu
-print the Book's ID, title, author and location; the name of the Patron whom it's requested by (if any); the name of the Patron whom it's checked out by (if any), and the number of days left till it's due (or the word "overdue").

be careful - a Book can be on request without its location being the hold shelf (if another Patron has it checked out);

Here is the HPP file:

This will be called Library.cpp

Explanation / Answer


#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip.h>

class library
{
   char bno[6];
   char bname[50];
   char aname[20];
    char holdings[50];
char admno[6];
   char name[20];
   char stbno[6];

  
public:
    library()
      {
            currentDate=0;
      }
   void add_book()
   {
       cout<<" NEW BOOK ENTRY... ";
       cout<<" Enter The book no.";
       cin>>bno;
       holdings[1]=bno;
       cout<<" Enter The Name of The Book ";
       gets(bname);
     
       cout<<" Enter The Author's Name ";
       gets(aname);
       cout<<" Book Created..";
   }
void add_member()
   {
       clrscr();
      cout<<" NEW STUDENT ENTRY... ";
       cout<<" Enter The admission no. ";
       cin>>admno;
       cout<<" Enter The Name of The Student ";
       gets(name);
       token=0;
       stbno[0]='/0';
       cout<<" Student Record Created..";
   }


   void show_book()
   {
       cout<<" Book no. : "<<bno;
         for(i=0;i<50;i++)
           {
             if(holdings[i]==bno)
              {
                  cout<<" Book Name : ";
                    puts(bname);
                 cout<<"Author Name : ";
                  puts(aname);
             }
              else
                cout<<"book is not present";
                        return;
   }

   void update_book()
{
   char n[6];
   int found=0;
   clrscr();
   cout<<" MODIFY BOOK REOCORD.... ";
   cout<<" Enter The book no. of The book";
   cin>>n;
   fp.open("book.dat",ios::in|ios::out);
   while(fp.read((char*)&bk,sizeof(book)) && found==0)
   {
       if(strcmpi(bk.retbno(),n)==0)
       {
           bk.show_book();
           cout<<" Enter The New Details of book"<<endl;
           bk.modify_book();
           int pos=-1*sizeof(bk);
               fp.seekp(pos,ios::cur);
               fp.write((char*)&bk,sizeof(book));
               cout<<" Record Updated";
               found=1;
       }
   }

       fp.close();
       if(found==0)
           cout<<" Record Not Found ";
       getch();
}
   char* retbno()
   {
       return bno;
   }

   void report()
   {cout<<bno<<setw(30)<<bname<<setw(30)<<aname<<endl;}


}