Document
Document
ArrayList;
import java.util.Scanner;
// Book class
class Book {
this.title = title;
this.author = author;
this.isAvailable = true;
return title;
return author;
return isAvailable;
}
public void borrowBook() {
if (isAvailable) {
isAvailable = false;
} else {
isAvailable = true;
@Override
return "Title: " + title + ", Author: " + author + ", Available: " +
(isAvailable ? "Yes" : "No");
// Library class
class Library {
public Library() {
books.add(book);
if (books.isEmpty()) {
return;
System.out.println(book);
if (book.getTitle().equalsIgnoreCase(title)) {
return book;
return null;
}
// Main class
while (true) {
System.out.println("\nLibrary Menu:");
System.out.println("4. Exit");
switch (choice) {
case 1:
library.displayBooks();
break;
case 2:
System.out.print("Enter book title to borrow: ");
if (borrowBook != null) {
borrowBook.borrowBook();
} else {
break;
case 3:
if (returnBook != null) {
returnBook.returnBook();
} else {
break;
case 4:
scanner.close();
return;
default:
}
}