Question
This is a C++ problem You will create a class representing an Abstract Data Type for a library book. This class will use several helper
This is a C++ problem
You will create a class representing an Abstract Data Type for a library book. This class will use several helper classes (via Class Aggregation [Gaddis Section 14.7]).
The helper classes, that you will write, are a date class, a name class, and a book class.
Each of your classes will include:
constructors
accessors
mutators
a display method which will use the accessor methods to (neatly) print its private data members.
a method to clear the data fields.
The private data members of each class:
class Name { private: string first_; string last_; }
class Date { private: int year_; int month_; int day_; }
class Book { private: Name author_; string title_; int year_; }
class LibraryBook { private: int id_; Book book_; Name borrower_; Date borrowed_; Date due_; bool isLoaned_; }
LibraryBook methods
constructors to create a LibraryBook object
accessors and mutators for each data member
(neatly) Print all information about this Library Book
print borrower and date information only if on loan
Loan the book:
parameters include borrowing date, due date, and borrower
Ensure that the due date is after the borrowing date (else do nothing other than print an error message)
if already out on loan, do nothing other than printing a message to that effect (can include due date).
Return the book:
Expunge the borrower name information and set isLoaned to false (if not loaned do nothing and print a message to that effect)
Renew the book:
Update the borrowing date and due date.
bool isOverdue(Date) const {compares parameter Date with borrowed Date}
if not loaned, print a message to that effect and return false
The following are components of your test driver program and not the LibraryBook class. However, they will use the LibraryBook class.
Declare a vector of LibraryBook objects, where each element corresponds to a different book.
Write a non-class function to read a set of Books from a file into the LibraryBook vector. (This will save you from having to manually input this information every time you run your program.)
Using the LibraryBook vector, write the following set of non-class functions (which will use LibraryBook class methods)
Print all library book record information for books out on loan
Print all library book record information for books not out on loan
Print all library book record information for books overdue
Print the information for that library book record which has a specific ID number
Print an appropriate message if there is no library book having the specified ID number
Print all library book record information (if not out on loan, ignore date and borrower information)
Your test driver program should call these functions before, during, and after you perform some borrowing and returning transactions.
Feel free to add to this functionality, with a menuing system, with other functions that use the LibraryBook class, and/or print the library book information in order sorted by some key.
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