Package com.miniproject.two
Class Main
java.lang.Object
com.miniproject.two.Main
Library Management System
This program provides a simple console-based library management system.
It allows users to add books, display a list of books, remove books,
search for books, borrow books, return books, and exit the system.
The program includes input validation, including ISBN validation for book
entries.
The main menu offers the following options:
- [1] Add Book: Prompts the user to enter details of a new book and adds it to the library.
- [2] Book List: Displays all the books currently in the library.
- [3] Remove Books: Prompts the user to enter a search term and removes matching books from the library.
- [4] Search Books: Prompts the user to enter a search term and displays matching books from the library.
- [5] Borrow Book: Prompts the user to enter the ISBN of a book to borrow and the borrower's name.
- [6] Return Book: Prompts the user to enter the ISBN of a book to return.
- [7] Exit: Exits the application with a thank you message.
- ISBN: Ensures that the ISBN is either a valid 10-digit or 13-digit number.
- Published Year: Ensures that the published year is a valid integer.
- Availability: Ensures that the availability status is either 'true' or 'false'.
- Since:
- 2024-06-25
- Version:
- 1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
borrowBookInterface
(Scanner scanner, Library library) Prompts the user to enter the ISBN and borrower name, and then calls the borrowBook method of the library object to borrow a book with the given ISBN and borrower name.static void
The main entry point of the Java program.protected static void
returnBookInterface
(Scanner scanner, Library library) Prompts the user to enter the ISBN of the book they want to return, and then calls the returnBook method of the library object to return the book with the given ISBN.
-
Constructor Details
-
Main
public Main()
-
-
Method Details
-
main
The main entry point of the Java program. This method creates a new instance of the Library class and initializes a Scanner object to read user input. It then enters a loop that displays a main menu and waits for user input. The user can choose from several options, including adding a book, displaying all books, removing a book, borrowing a book, returning a book, searching for a book, and quitting the program.- Parameters:
args
- the command line arguments
-
borrowBookInterface
Prompts the user to enter the ISBN and borrower name, and then calls the borrowBook method of the library object to borrow a book with the given ISBN and borrower name.- Parameters:
scanner
- the Scanner object used for user inputlibrary
- the Library object where the book will be borrowed
-
returnBookInterface
Prompts the user to enter the ISBN of the book they want to return, and then calls the returnBook method of the library object to return the book with the given ISBN.- Parameters:
scanner
- the Scanner object used for user inputlibrary
- the Library object from which the book will be returned
-