Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your task is to implement a Catalog ofBooks. 1. For this first you have toimplem

ID: 3610061 • Letter: Y

Question

Your task is to implement a Catalog ofBooks.

1.      For this first you have toimplement Book class The Book class is a simpleclass to store information about a particular book and it has thefollowing data members:

Write default and parameterized constructors and setters gettersfor the Book class.

2.      Catalog classis a linked list of Book objects and that can perform the followingfunctionality.

o       Addmethod to add a book in the Catalog

o      printAllBooks method to print all the books in theCatalog.

o      searchByAuthor method will take author name as anargument and will find a book written by that author.

o       Availablemethod to print all those books that are currently available. Ifthe status of a book is false than it means that book is notavailable, if the status is true then it means book isavailable.

3.      Include a main function asfollows:

Hint:

Make Nodes of Book type and then link them tomake Catalog linked list. It means there will beanother class between Book and Catalog and that isBookNode class.

Explanation / Answer

Dear check this out, makesome changes in it, it will help you alot. thanks ------------------------------------ thanks ------------------------------------ Dear check this out, makesome changes in it, it will help you alot. thanks ------------------------------------ import java.io.*;
import java.lang.*;
import java.util.*;


class Book {

/* attributes */
private String title;
private String author;
private String ISBN;
private boolean status;

/*constructors */
public Book(){
this.title="" ;
this.author ="" ;
this.ISBN ="" ;
this.status =false ;
}

public Book(String title, String author, String ISBN, booleanstatus){
this.title=title ;
this.author =author ;
this.ISBN =ISBN ;
this.status =true ;
}

/** set and get methods */
public String getTitle(){
return this.title ;
}

public void setTitle(String title){
this.title = title ;
}

public String getAuthor(){
return this.author ;
}

public void setAuthor(String author ){
this.author =author ;
}

public String getISBN(){
return this.ISBN ;
}

public void setISBN(String ISBN){
this.ISBN =ISBN ;
}

public boolean getStatus(){
return this.status ;
}

public void setStatus(boolean status ){
this.status = status;
}

} //end of book class




public class Catalog
{

   public static LinkedList<Book>library;

   public Catalog(){
       library   = newLinkedList<Book>();
   }

   public void add(Book book){
   library.add(book);
   }

   public void printAllBooks(){

   for (Book b : library)
      System.out.println("Title: " +b.getTitle() +" Author: "+b.getAuthor()+"  ISBN: " +b.getISBN()+"   status: "+b.getStatus());
   }

   public void searchByAuthor(String author){
   for (Book b : library)
   {
       if(author.equals (b.getAuthor()))
       {
         System.out.println("Title: " + b.getTitle() +" Author: "+b.getAuthor()+"   ISBN: "+b.getISBN()+"   status: "+b.getStatus());
          return;
        }
   }
   System.out.println("the book written by "+author + " is not there in tha catalog");
   }

   public void available(){

    for (Book b : library)
    {
    if(b.getStatus()){
      System.out.println("Title: " +b.getTitle() +" Author: "+b.getAuthor()+"  ISBN: " +b.getISBN()+"   status: "+b.getStatus());
      }
   }
   }



    public static void main(String[] args){
  
    Book b1 = new Book("Let us C", "krishna" ,"12345-AD" , true);
    Book b2 = new Book("Introduction to algorithms","cormon" , "1dfsd45-AD" , true);
    Book b3 = new Book("Introduction to java","newton" , "123sfsdfds23435D" , true);
    Book b4 = new Book("Sherlock holmes", "conandoyle" , "56565-JKR" , true);
    Book b5 = new Book("discrete structures","kenneth rosan" , "13456-TM" , true);
    b3.setStatus(false);
  
    Catalog c = new Catalog();
    c.add(b1); c.add(b2); c.add(b3); c.add(b4);c.add(b5);
    System.out.println("printing All Books");
    c.printAllBooks();
    System.out.println();
  
    System.out.println("Searching Book written Bycormon");
    c.searchByAuthor("cormon");
    System.out.println();
  
    System.out.println("Printing the availableBooks");
    c.available();
    System.out.println();
  
    }
  
}