HA03
HA03
Home Assignment 03
Out: Oct 7, 2024, Due: 11:55pm - Oct 13, 2024
Lead TA(s): Faheem Shehzad
“I certify that I have neither received nor given unpermitted aid on this examination and
that I have reported all such incidents observed by me in which unpermitted aid is given.”
Zip your assignment folder and rename it to ’<rollnumer>_HA3.zip’. Upload your zip file in
the corresponding LMS submission tab. Example, ’26100036_HA3.zip’
1 Introduction
The Library Management System is designed to manage the collection of books in a library as
well as the borrowers who check them out. The system allows adding, removing, displaying, and
searching for books, managing borrowers, and handling the borrowing and returning of books,
including late fees.
2 System Requirements
You are to implement the system with the following classes:
2.1.1 Attributes
• title: A string representing the title of the book.
• dueDate: A string representing the due date for returning the book (format: "YYYY-
MM-DD").
2.1.2 Methods
• Book(): A default constructor that initializes the book’s title and author to "Unknown",
the book ID to -1, isBorrowed to false, and dueDate to an empty string.
1
• setBook(string utitle, string uauthor, int ubookID): A method to set or update
the book’s details.
• returnBook():
A method to mark the book as returned. If the book was not borrowed, it should return
false.
2.2.1 Attributes
• name: A string representing the name of the borrower.
• MAX_BOOKS: A constant representing the maximum number of books a borrower can bor-
row at once (e.g., 5 books).
2.2.2 Methods
• Borrower(string uname, int uborrowerID): A constructor to initialize a borrower
with given details.
• returnBook(Book &book): Allows the borrower to return a book. The method should
return true if the operation was successful and display the late fee if applicable. Make
sure you cannot return a non-existant book.
2
2.3 Library Class
The Library class manages the collection of books and borrowers. It includes the following
attributes and methods:
2.3.1 Attributes
• books: An array of Book objects, representing the catalog of books in the library.
• borrowers: An array of Borrower objects, representing the borrowers registered with the
library.
2.3.2 Methods
• addBook(Book book): Adds a new book to the library’s catalog if there is available
capacity. It should return true or false depending on whether it was successful.
• removeBook(int bookID): Removes a book from the catalog based on its ID. It should
return true or false depending on whether it was successful. Make sure you can’t remove
a non-existant book and return false.
• searchBook(int bookID): Allows the user to search for a book based on its ID. If the
ID is found, it should return a reference to that book.
3 Example Usage
The following is an example of how the program might be used:
• The user adds a new book titled "The Great Gatsby" by F. Scott Fitzgerald with ID 2001.
• The user registers a new borrower named "Alice Johnson" with ID 3001.
• Alice Johnson borrows "The Great Gatsby" with a due date of "2024-11-01".
3
• Alice Johnson returns the book after the due date and is charged a late fee.
Testing will be done with the provided main in the file. Submission to be done
on LMS. Use the naming convention <roll_number>_HA3.zip. If this naming
convention will not be used 10% will be deducted from your grade for this take
home lab.