Lesson 25 of 25

Final Project: Build a Java App

Project Overview

Build a complete Library Management System that demonstrates all Java concepts you've learned.

  • Object-oriented design with classes, interfaces, and inheritance
  • Collections for storing books, members, and loans
  • File I/O for data persistence
  • Exception handling for robust error management
  • Streams and lambdas for data processing
  • Encapsulation and proper access control

Core Classes

Start by designing the class hierarchy for the library system.

Example
// Book.java
public class Book {
    private final String isbn;
    private String title;
    private String author;
    private boolean available;

    public Book(String isbn, String title, String author) {
        this.isbn = isbn;
        this.title = title;
        this.author = author;
        this.available = true;
    }

    public boolean isAvailable() { return available; }
    public void checkout() { available = false; }
    public void returnBook() { available = true; }

    @Override
    public String toString() {
        return String.format("%s by %s [%s] %s",
            title, author, isbn,
            available ? "Available" : "Checked Out");
    }
}

// Library.java
public class Library {
    private Map<String, Book> books = new HashMap<>();
    private List<Loan> loans = new ArrayList<>();

    public void addBook(Book book) { books.put(book.getIsbn(), book); }

    public List<Book> searchByAuthor(String author) {
        return books.values().stream()
            .filter(b -> b.getAuthor().equalsIgnoreCase(author))
            .collect(Collectors.toList());
    }

    public long countAvailable() {
        return books.values().stream().filter(Book::isAvailable).count();
    }
}