This code is a simple library management system. It allows...
This code is a simple library management system. It allows users to log in as either a user or an admin, and perform various operations such as borrowing a book, displaying the book inventory, adding a new book, and returning a book.
The code defines three classes: Book
, User
, and Library
. The Book
class represents a book with properties such as title, author, and year. The User
class represents a user with properties such as username and userID. The Library
class represents the library itself, with properties such as a vector of books and a vector of users.
The Library
class has several member functions. The displayBooks
function displays the current book inventory. The displayBooksForAddNewBooks
function displays the book inventory for adding new books. The borrowBook
function allows a user to borrow a book by entering the title of the book they want to borrow. The addNewBook
function allows an admin to add a new book to the inventory by entering the title, author, and publication year of the book. The returnBook
function allows a user to return a borrowed book by entering the title of the book they want to return.
The main
function is the entry point of the program. It prompts the user to choose a role (user or admin) and then prompts for a username and password. If the login is successful, it initializes a Library
object and populates the book inventory. It then displays a menu of options for the user to choose from, and performs the corresponding action based on the user's choice. The program continues to display the menu until the user chooses to exit.
Overall, this code provides a basic implementation of a library management system with user and admin functionality.