0% found this document useful (0 votes)
6 views4 pages

HA03

Uploaded by

Abdul Samee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

HA03

Uploaded by

Abdul Samee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CS300: Fall 2024-2025 Home Assignment 03 - SET 1

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 Book Class


The Book class represents a book in the library. It should include the following attributes and
methods:

2.1.1 Attributes
• title: A string representing the title of the book.

• author: A string representing the author of the book.

• bookID: An integer representing a unique ID for the book.

• isBorrowed: A boolean indicating whether the book is currently borrowed.

• 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.

• Book(string utitle, string uauthor, int ubookID): A parameterized constructor


to initialize a book with given details.

1
• setBook(string utitle, string uauthor, int ubookID): A method to set or update
the book’s details.

• getBookID(): A method to retrieve the book’s unique ID.

• getTitle(): A method to retrieve the book’s title.

• getAuthor(): A method to retrieve the book’s author.

• borrowBook(string udueDate): A method to mark the book as borrowed with a due


date. If the book is already borrowed, it should return false; otherwise, it should return
true.

• returnBook():
A method to mark the book as returned. If the book was not borrowed, it should return
false.

2.2 Borrower Class


The Borrower class represents a person who borrows books from the library. It includes the
following attributes and methods:

2.2.1 Attributes
• name: A string representing the name of the borrower.

• borrowerID: An integer representing a unique ID for the borrower.

• borrowedBooks: An array of Book objects representing the books currently borrowed by


the borrower.

• borrowedCount: An integer tracking the number of books currently borrowed.

• 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.

• borrowBook(Book &book, string dueDate): Allows the borrower to borrow a book


if they have not exceeded the MAX_BOOKS limit. The method should return true if the
operation was successful, or false otherwise. Make sure you dont allow someone to borrow
a book already borrowed.

• 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.

• getBorrowerID(): A method to retrieve the borrower’s unique ID.

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.

• currentBookCount: An integer tracking the current number of books in the library.

• currentBorrowerCount: An integer tracking the current number of registered borrowers.

• BOOK_CAPACITY: A constant representing the maximum capacity of books in the library


(e.g., 200 books).

• BORROWER_CAPACITY: A constant representing the maximum number of borrowers the


library can register (e.g., 100 borrowers).

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.

• addBorrower(Borrower borrower): Registers a new borrower if there is available ca-


pacity. It should return true or false depending on whether it was successful.

• removeBorrower(int borrowerID): Removes a borrower based on their ID. It should


return true or false depending on whether it was successful. Make sure you can’t remove
a non-existant borrower.

• searchBorrower(int borrowerID): Allows the user to search for a borrower based on


their ID. If the ID is found, it should return a reference to that borrower.

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.

• The user displays the list of all books and borrowers.

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.

You might also like