Question: Update the comments on the code below and create a Javadoc. public class Book { private String bookId; private String title; private String author; private
Update the comments on the code below and create a Javadoc.
public class Book
private String bookId;
private String title;
private String author;
private boolean availability;
private String borrower;
Default constructor
public Book
this.bookId ;
this.title ;
this.author ;
this.availability true;
this.borrower ;
Parameterized constructor
public BookString bookId, String title, String author, boolean availability
setBookIdbookId;
setTitletitle;
setAuthorauthor;
this.availability availability;
this.borrower ;
Getter and Setter for bookId
public String getBookId
return bookId;
public void setBookIdString bookId
if bookId null bookId.isEmpty
throw new IllegalArgumentExceptionBook ID cannot be null or empty";
this.bookId bookId;
Getter and Setter for title
public String getTitle
return title;
public void setTitleString title
if title null title.isEmpty
throw new IllegalArgumentExceptionTitle cannot be null or empty";
this.title title;
Getter and Setter for author
public String getAuthor
return author;
public void setAuthorString author
if author null author.isEmpty
throw new IllegalArgumentExceptionAuthor cannot be null or empty";
this.author author;
Getter and Setter for availability
public boolean isAvailable
return availability;
public void setAvailabilityboolean availability
this.availability availability;
Getter and Setter for borrower
public String getBorrower
return borrower;
public void setBorrowerString borrower
this.borrower borrower;
@Override
public String toString
return "Book ID: bookId Title: title Author: author
Available: availability Borrower: borrower;
LibraryManagementSystem Class
import java.util.Scanner;
public class LibraryManagementSystem
private Book books;
private int bookCount;
Constructor
public LibraryManagementSystemint capacity
books new Bookcapacity;
bookCount ;
Add a new book
public void addBookString bookId, String title, String author, boolean availability
for int i ; i bookCount; i
if booksigetBookIdequalsbookId
System.out.printlnBook ID already exists.";
return;
booksbookCount new BookbookId title, author, availability;
System.out.printlnBook added successfully.";
Display all books
public void displayAllBooks
for int i ; i bookCount; i
System.out.printlnbooksi;
Search for a book
public void searchBookString bookId
for int i ; i bookCount; i
if booksigetBookIdequalsbookId
System.out.printlnbooksi;
return;
System.out.printlnBook not found.";
Borrow a book
public void borrowBookString bookId, String borrower
for int i ; i bookCount; i
if booksigetBookIdequalsbookId
if booksiisAvailable
booksisetAvailabilityfalse;
booksisetBorrowerborrower;
System.out.printlnBook borrowed successfully.";
else
System.out.printlnBook is currently unavailable.";
return;
System.out.printlnBook not found.";
Return a book
public void returnBookString bookId
for int i ; i bookCount; i
if booksigetBookIdequalsbookId
if booksiisAvailable
booksisetAvailabilitytrue;
booksisetBorrower;
System.out.printlnBook returned successfully.";
else
System.out.printlnBook was not borrowed.";
return;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
