Library Management System
The Library Management System is a console-based application designed to manage library operations efficiently. This system handles two primary types of users: regular users and librarians. Regular users can borrow, return, and view books, while librarians can manage the library by adding/removing books, borrowing books, and performing various administrative tasks.
-
Clone the repository:
git clone https://github.com/your-repository/LibrarySystem.git
-
Open the project in Visual Studio or any C# IDE.
-
Build the project to restore the necessary packages and compile the application.
-
Run the application using your IDE or from the terminal:
dotnet run
Upon running the application, users will be prompted to select their role:
-
Regular User Actions:
- Display all available books.
- Borrow a book.
- Return a borrowed book.
-
Librarian Actions:
- Display all books in the library.
- Borrow a book.
- Add a new book to the library.
- Remove a book from the library.
- Return a borrowed book.
Both regular users and librarians must identify whether they are new or existing users, which involves entering their name, and for regular users, a library card number.
- User Management: Supports new and existing users (both regular users and librarians).
- Book Management: Add, remove, borrow, and return books.
- User Role Management: Differentiates between regular users and librarians with distinct capabilities.
- Borrowing and Returning Books: Both regular users and librarians can borrow or return books.
- Validation: Ensures users enter valid inputs (e.g., book details, user names, year of publication).
- Reusability: The program allows for repeated actions such as borrowing and returning books.
- .NET 5.0 or higher: This project uses C# and runs on the .NET framework.
- C# Standard Libraries: The application uses built-in libraries such as
System,System.Collections.Generic,System.Linq, etc.
There are no external configurations for this project. Configuration happens through user input, such as entering the type of user (regular user or librarian) and interacting with the library (adding books, borrowing books, etc.).
The system has the following core classes:
- Library: Manages the collection of books and users. Provides methods for adding, removing, borrowing, and displaying books.
- Book: Represents a book in the library with properties like
Title,Author, andYear. - User: The base class for all users (both regular users and librarians).
- LibraryUser: Derived from
User, represents regular users who interact with books in the library. - Librian: Derived from
User, represents librarians who manage the library. - LibraryCard: Represents a unique card number for a regular user.
- The user is prompted to enter whether they are a new or old user.
- A new regular user enters their name and card number.
- The user can then choose to borrow a book, display books, or return a borrowed book.
Welcome to our Library
Are you Librarian or Regular User (L/R):
R
Please enter your data:
Enter your name: Alice
Enter your card number: 1234
Welcome to our library, Alice!
You can display books (D), borrow a book (B), or return a book (Z).
Choose what you want: B
Enter details for the book you need:
Enter book title: C# Programming
Enter book author: John Doe
Enter book year: 2021
You borrowed this book successfully- The librarian enters their name and employee number.
- They can choose to add a new book to the library.
Welcome to our Library
Are you Librarian or Regular User (L/R):
L
Please enter your data:
Enter your name: Bob
Enter your employee number: 5678
Welcome to our library, Bob!
You can display books (D), borrow a book (B), add a book (A), or remove a book (R).
Choose what you want: A
Enter details for the book to add:
Enter book title: Advanced C#
Enter book author: Jane Smith
Enter book year: 2020
This book has been added successfully.-
Error: "Book not found"
- Ensure the book you are trying to borrow or return is listed in the library’s collection.
-
Error: "Invalid year"
- Ensure that you enter a valid year when prompted for book details.
-
Error: "User does not exist"
- Ensure that you are entering the correct name for an existing user.
This README provides an overview of the Library Management System and should guide users through its setup, usage, and troubleshooting.