Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

JavabeginnercliAI generated

Console-Based Library Management System

Build a library management program in Java for the console: librarians add books and members, search the catalog by title or author, lend books with a due date two weeks later, record returns, and see which books are overdue, all from a numbered menu. Data is kept in memory with Java collections during the session. Rules are enforced: a book can't be lent twice, members can borrow at most 3 books, and members with overdue books can't borrow more. It's a great first Java project: you'll learn designing classes, collections such as Map and List, reading input with Scanner, dates with LocalDate, handling mistakes with exceptions, and testing with JUnit.

Estimate
~7.5h
Steps
5
Completed by
0
Proposed by
codeseed.app

Java Collections · Scanner

Project roadmap

  1. 01

    Design the classes

    ~1.5h

    Create classes Book (id, title, author and year), Member (id and name) and Loan (book, member, loan date, due date and return date), and a Library class holding books and members in Maps by id and loans in a List. Give each class a sensible toString for printing. Done when: the classes compile, and a Library can be filled with sample data.

  2. 02

    Build the console menu

    ~1.5h

    Write a menu loop with Scanner offering: add book, add member, search books, lend book, return book, list loans, list overdue loans and quit. Read numbers safely (re-asking when the input isn't a number) and show clear messages. Done when: the menu runs and every option can be chosen.

  3. 03

    Implement the operations

    ~1.5h

    Implement searching (case-insensitive, by part of the title or author), lending (creating a Loan with a due date 14 days after today) and returning (setting the return date), and listing current loans with the member, book and due date. Done when: books can be found, lent and returned from the menu.

  4. 04

    Add the rules

    ~1.5h

    Enforce the rules in the Library class, throwing your own exceptions with clear messages: a book already on loan can't be lent, a member can have at most 3 loans, and members with overdue books can't borrow. List overdue loans with the number of days overdue using LocalDate and ChronoUnit.DAYS.between. Let the Library take the current date as a parameter so tests can control it. Done when: each rule is enforced with a clear message, and overdue loans are listed correctly.

  5. 05

    Write unit tests

    ~1.5h

    Write JUnit 5 tests for the Library class: adding and searching, lending and returning, each rule (including the exact limit of 3 books), and overdue calculations with fixed dates (due today, one day late and returned late). Done when: all tests pass.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~7.5h · 5 steps

Tech stack

Java CollectionsScanner