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

I have a method that takes in a LibraryMaterialCopy object. This methods renews

ID: 3837328 • Letter: I

Question

I have a method that takes in a LibraryMaterialCopy object. This methods renews a book.

public boolean renewLibraryMaterial(LibraryMaterialCopy libraryMaterial, LocalDate renewalDate)
   // renews libraryMaterial. Returns false if libraryMaterial is not checked
   // out already
   // takes parameter that expresses date of renewal
   // returns false if librayrMaterial is not a book
   {
       if (!libraryMaterialsCheckedOut.contains(libraryMaterial))
           return false;

       if (libraryMaterial.isRenewable()) {
          
           if (!((BookCopy) libraryMaterial).renew(renewalDate))
               return false;
          
           return true;
       }
       return false;
   }

My main is asking for the user to enter the name of the book they want to renew, but I have it as a string.

System.out.println("Enter Your Library Card ID Number");
               String ID5 = input.next();
               System.out.println("Enter the Book's Title to Renew");
               String Title3 = input.next();
               LibraryCard RenewBook = Card.getCardByID(ID5);
               RenewBook.renewLibraryMaterial(Title3);

How do I have it where the user enters it as an object? My code is posted below.

LibraryMaterialCopy.java

import java.time.LocalDate;

public abstract class LibraryMaterialCopy {
   protected LibraryCard card;
   protected LocalDate dueDate;

   public LibraryMaterialCopy() {
       card = null;
       dueDate = null;
   }

   public abstract LibraryMaterial getLibraryMaterial();
   public abstract String getTitle();
   public abstract String getISBN();
   public abstract int getBorrowingWeeks();
   public abstract double getFinePerDay();
   public abstract boolean isRenewable();
   public abstract boolean isTitle(String s);

   public LibraryCard getCard() {
       return card;
   }

   public LocalDate getDueDate() {
       return dueDate;
   }

   public boolean checkOut(LibraryCard borrower, LocalDate dateOfBorrowing)
   /*
   * checks book out by setting card reference to borrower. returns false if
   * book is already checked out sets due date to BORROWING_WEEKS after
   * current date passed
   */
   {
       if (card != null)
           return false;

       card = borrower;
       dueDate = dateOfBorrowing.plusWeeks(getBorrowingWeeks());

       return true;
   }

   public boolean checkOut(LibraryCard borrower)
   // default check out method that uses todays' date
   {
       return checkOut(borrower, LocalDate.now());
   }

   public boolean returnCopy()
   // returns book by removing card reference
   // returns false if there is no reference to a card
   {
       if (card == null)
           return false;

       card = null;

       return true;
   }

   public void print() {
       if (card != null) {
           System.out.println("Checked out to: " + card.getCardholderName() + ", " + card.getID());
           System.out.println("Due: " + dueDate);
       }
  

LibraryMaterial.java

public class LibraryMaterial {

   private String ISBN;
   private String title;

   public LibraryMaterial(String i, String t) {
       ISBN = i;
       title = t;
   }

   public String getISBN() {
       return ISBN;
   }

   public String getTitle() {
       return title;
   }

   public void print() {
       System.out.print("ISBN: " + ISBN + " title: " + title + " ");
   }
  
   public boolean isTitle(String s) {
  
       if(this.title.equals(s))
           return true;
      
       return false;
   }
}

Explanation / Answer

To use renewLibraryMaterial methon you need to create object of LibraryMaterialCopy sub class.

int below case you need to create object of BookCopy class useing LibraryCard and title , somthing like below

System.out.println("Enter Your Library Card ID Number");
               String ID5 = input.next();
               System.out.println("Enter the Book's Title to Renew");
               String Title3 = input.next();
               LibraryCard RenewBook = Card.getCardByID(ID5);
               RenewBook.renewLibraryMaterial(new BookCopy(RenewBook ,Title3 ), date);

I can correct but you didn't uploaded all code for example : RenewBook class LocalDate class etc

Please upload all code if you need correction