Class Main

java.lang.Object
com.miniproject.two.Main

public class Main extends Object
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.
Input validation includes:
  • 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'.
The program uses ANSI escape codes for color formatting in the console.
Since:
2024-06-25
Version:
1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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
    main(String[] args)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Main

      public Main()
  • Method Details

    • main

      public static void main(String[] args)
      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

      protected 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.
      Parameters:
      scanner - the Scanner object used for user input
      library - the Library object where the book will be borrowed
    • returnBookInterface

      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.
      Parameters:
      scanner - the Scanner object used for user input
      library - the Library object from which the book will be returned