Question

Modify the library program as follows: Create a method in the LibraryMaterial class that accepts a...

Modify the library program as follows:

Create a method in the LibraryMaterial class that accepts a string s as a parameter and returns true if the title of the string is equal to s.
Create the same method for your library material copies. Note that it will need to be abstract in the LibraryMaterialCopy class

MY CODE

****************************************************************

LibraryCard:

import java.util.List;

import java.util.ArrayList;

import java.time.LocalDate;

import    java.time.temporal.ChronoUnit;

public class LibraryCard {

   private String id;

   private String cardholderName;

   private List<LibraryMaterialCopy> libraryMaterialsCheckedOut;

   private double balance;

   public LibraryCard(String i, String name)

   {

       id = i;

       cardholderName = name;

       libraryMaterialsCheckedOut = new ArrayList<LibraryMaterialCopy>();

     balance = 0;

   }

   public String getID() {return id;}

   public String getCardholderName() {return cardholderName;}

   public List<LibraryMaterialCopy> getlibraryMaterialsCheckedOut() {

       return new ArrayList<LibraryMaterialCopy>(libraryMaterialsCheckedOut);}

   public void setCardholderName (String name) {cardholderName = name;}

   public boolean checkOutLibraryMaterial (LibraryMaterialCopy libraryMaterial, LocalDate todaysDate)

   {

       if (!libraryMaterial.checkOut(this))

           return false;

       libraryMaterialsCheckedOut.add(libraryMaterial);

       return true;

   }

   public boolean checkOutLibraryMaterial(LibraryMaterialCopy libraryMaterial)

   //default check out, uses today's date

   {

       return checkOutLibraryMaterial(libraryMaterial, LocalDate.now());

   }

   public boolean returnLibraryMaterial (LibraryMaterialCopy libraryMaterial, LocalDate returnDate)

   //returns libraryMaterial and sends message to libraryMaterialCopy to do the same

   //returns false if libraryMaterial is not checked out

   //takes parameter that expresses the date of return

   {

       LocalDate dueDate = libraryMaterial.getDueDate();

       if (!libraryMaterial.returnCopy())

           return false;

       if (!libraryMaterialsCheckedOut.remove(libraryMaterial))

           return false;

       long daysBetween = ChronoUnit.DAYS.between(dueDate, returnDate);

       if (daysBetween > 0) //libraryMaterial is returned late

       {

           balance += libraryMaterial.getFinePerDay() * daysBetween;

       }

       return true;

   }

   public boolean returnLibraryMaterial (LibraryMaterialCopy libraryMaterial)

   //default method, uses today's date as returns date

   {

       return returnLibraryMaterial(libraryMaterial, LocalDate.now());

   }

   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;

   }

   public boolean renewLibraryMaterial (LibraryMaterialCopy libraryMaterial)

   //default renewal method uses today's date as renewal date.

   {

       return renewLibraryMaterial(libraryMaterial, LocalDate.now());

   }

   public List<LibraryMaterialCopy> getlibraryMaterialsDueBy(LocalDate date)

   //returns an List of libraryMaterials due on or before date

   {

       List<LibraryMaterialCopy> libraryMaterialsDue = new ArrayList<LibraryMaterialCopy>();

       for (LibraryMaterialCopy libraryMaterial: libraryMaterialsCheckedOut)

       {

           if (libraryMaterial.getDueDate().isBefore(date) || libraryMaterial.getDueDate().equals(date))

           {

               libraryMaterialsDue.add(libraryMaterial);

           }

       }

     

       return libraryMaterialsDue;

   }

   public List<LibraryMaterialCopy> getLibraryMaterialsOverdue (LocalDate todaysDate)

   {

       return getlibraryMaterialsDueBy(todaysDate.minusDays(1));

   }

   public List<LibraryMaterialCopy> getLibraryMaterialsOverdue()

   //default method, returns libraryMaterials overdue as of today, which means that they

   //were due by yesterday

   {

       return getLibraryMaterialsOverdue(LocalDate.now());

   }

   public List<LibraryMaterialCopy> getLibraryMaterialsSorted()

   //returns List of libraryMaterials, sorted by due date (earliest due date first)

   //uses insertion sort

   {

       List<LibraryMaterialCopy> libraryMaterials = new ArrayList<LibraryMaterialCopy>(libraryMaterialsCheckedOut);

       for (int i = 1; i < libraryMaterials.size(); i++)

       {

           int j = i;

           while (j > 0 && libraryMaterials.get(j-1).getDueDate().isAfter(libraryMaterials.get(j).getDueDate()))

           {

             

               //swap elements in positions j and j-1

               LibraryMaterialCopy temp = libraryMaterials.get(j);

               libraryMaterials.set(j, libraryMaterials.get(j-1));

               libraryMaterials.set(j-1, temp);

             

               j = j-1;

           }

       }

       return libraryMaterials;

   }

}

LibraryMaterial.java:

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 + " ");

   }

}

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 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);

       }

   }

}

Book.java:

public class Book extends LibraryMaterial

{

   private String author;

   public Book(String i, String t, String a)

   {

       super(i, t);

       author = a;

   }

   public String getAuthor(){return author;}

   public void print()

   {

       super.print();

       System.out.println("author: " + author);

   }

}

BookCopy.java:

import java.time.*;

public class BookCopy extends LibraryMaterialCopy {

   private Book book;

   public static final int BORROWING_WEEKS = 3;

   public static final int RENEWAL_WEEKS = 2;

   public static final double FINE_PER_DAY = .10;

   public static final boolean IS_RENEWABLE = true;

   public BookCopy(Book b)

   {

       super();

       book = b;

   }

   @Override

   public LibraryMaterial getLibraryMaterial() {

       return book;

   }

   @Override

   public int getBorrowingWeeks() {return BORROWING_WEEKS;}

   @Override

   public double getFinePerDay() {return FINE_PER_DAY;}

   @Override

   public String getTitle(){return book.getTitle();}

   @Override

   public String getISBN(){return book.getISBN();}

   public String getAuthor() {return book.getAuthor();}

   @Override

   public boolean isRenewable(){return IS_RENEWABLE;}

   public boolean renew (LocalDate renewalDate)

   {

       if (card == null)

           return false;

       dueDate = renewalDate.plusWeeks(RENEWAL_WEEKS);

       return true;

   }

   public boolean renew ()

   //default method uses todays date as renewal date

   {

       return renew(LocalDate.now());

   }

   public void print()

   {

       book.print();

       super.print();

   }

}

DVD.java:

public class DVD extends LibraryMaterial {

   private String mainActor;

   public DVD (String i, String t, String mA)

   {

       super(i, t);

       mainActor = mA;

   }

   public String getMainActor(){return mainActor;}

   public void print()

   {

       super.print();

       System.out.println("Main actor: " + mainActor);

   }

}

DVDCopy.java:

public class DVDCopy extends LibraryMaterialCopy {

   public static final int BORROWING_WEEKS = 2;

   public static final double FINE_PER_DAY = 1;

   public static final boolean IS_RENEWABLE = false;

   private DVD dvd;

   public DVDCopy(DVD d)

   {

       super();

       dvd = d;

   }

   @Override

   public LibraryMaterial getLibraryMaterial() {

       return dvd;

   }

   @Override

   public String getTitle() {

       return dvd.getTitle();

   }

   @Override

   public String getISBN() {

       return dvd.getISBN();

   }

   public String getMainActor()

   {

       return dvd.getMainActor();

   }

   @Override

   public int getBorrowingWeeks() {return BORROWING_WEEKS;}

   @Override

   public double getFinePerDay() {return FINE_PER_DAY;}

   @Override

   public boolean isRenewable() {return IS_RENEWABLE;}

   public void print()

   {

       dvd.print();

       super.print();

   }

}

mainProgram.java:

import java.util.ArrayList;

import java.util.List;

import java.time.LocalDate;

public class mainProgram {

   public static void main(String[] args) {

       ArrayList<LibraryMaterial> books = new ArrayList<LibraryMaterial>();

       books.add(new Book("12345678910", "Harry Potter", "J. K. Rowling"));

       books.add (new Book ("98765432", "Berenstein Bears", "Stan and Jan"));

       books.add (new Book ("6547901", "Curious George", "No Clue"));

       books.add (new Book("5678322222", "Samantha", "Me Myself"));

     

       ArrayList<LibraryMaterialCopy> bookCopies = new ArrayList<LibraryMaterialCopy>();

       for (LibraryMaterial b: books)

       {

           bookCopies.add(new BookCopy ((Book)b));

       }

     

       ArrayList<LibraryCard> cards = new ArrayList();

       cards.add(new LibraryCard ("123456", "Devorah Kletenik"));

       cards.add (new LibraryCard ("87654", "Me and Me"));

       cards.add (new LibraryCard ("8887654", "Sarah Kletenik"));

     

       for (LibraryMaterialCopy bc: bookCopies)

       {

           System.out.println(cards.get(0).checkOutLibraryMaterial(bc));

           System.out.println(cards.get(1).checkOutLibraryMaterial(bc));

           System.out.println(cards.get(2).checkOutLibraryMaterial(bc));

         

       }

     

       List<LibraryMaterialCopy> bookCopies2 = cards.get(0).getLibraryMaterialsSorted();

       for (LibraryMaterialCopy book: bookCopies2)

           System.out.println(book.getTitle() + " " + book.getDueDate());

     

       System.out.println("got here");

       System.out.println(bookCopies.get(3).getTitle());

       ((BookCopy)bookCopies.get(3)).renew();

     

       System.out.println("renewed");

     

       bookCopies2 = cards.get(0).getLibraryMaterialsSorted();

       System.out.println("and here again");

       for (LibraryMaterialCopy book: bookCopies2)

           System.out.println(book.getTitle() + " " + book.getDueDate());

     

       System.out.println("here again");

     

     

       for (LibraryMaterialCopy bc: bookCopies)

       {

           System.out.println(cards.get(0).returnLibraryMaterial(bc));

           System.out.println(cards.get(1).returnLibraryMaterial(bc));

           System.out.println(cards.get(2).returnLibraryMaterial(bc));

       }

             

   }

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is your program : -

LibraryCard.java

import java.util.List;
import java.util.ArrayList;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

public class LibraryCard {
   private String id;
   private String cardholderName;
   private List<LibraryMaterialCopy> libraryMaterialsCheckedOut;
   private double balance;

   public LibraryCard(String i, String name) {
       id = i;
       cardholderName = name;
       libraryMaterialsCheckedOut = new ArrayList<LibraryMaterialCopy>();
       balance = 0;
   }

   public String getID() {
       return id;
   }

   public String getCardholderName() {
       return cardholderName;
   }

   public List<LibraryMaterialCopy> getlibraryMaterialsCheckedOut() {
       return new ArrayList<LibraryMaterialCopy>(libraryMaterialsCheckedOut);
   }

   public void setCardholderName(String name) {
       cardholderName = name;
   }

   public boolean checkOutLibraryMaterial(LibraryMaterialCopy libraryMaterial, LocalDate todaysDate) {
       if (!libraryMaterial.checkOut(this))
           return false;
       libraryMaterialsCheckedOut.add(libraryMaterial);
       return true;
   }

   public boolean checkOutLibraryMaterial(LibraryMaterialCopy libraryMaterial)
   // default check out, uses today's date
   {
       return checkOutLibraryMaterial(libraryMaterial, LocalDate.now());
   }

   public boolean returnLibraryMaterial(LibraryMaterialCopy libraryMaterial, LocalDate returnDate)
   // returns libraryMaterial and sends message to libraryMaterialCopy to do
   // the same
   // returns false if libraryMaterial is not checked out
   // takes parameter that expresses the date of return
   {
       LocalDate dueDate = libraryMaterial.getDueDate();
       if (!libraryMaterial.returnCopy())
           return false;
       if (!libraryMaterialsCheckedOut.remove(libraryMaterial))
           return false;
       long daysBetween = ChronoUnit.DAYS.between(dueDate, returnDate);
       if (daysBetween > 0) // libraryMaterial is returned late
       {
           balance += libraryMaterial.getFinePerDay() * daysBetween;
       }
       return true;
   }

   public boolean returnLibraryMaterial(LibraryMaterialCopy libraryMaterial)
   // default method, uses today's date as returns date
   {
       return returnLibraryMaterial(libraryMaterial, LocalDate.now());
   }

   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;
   }

   public boolean renewLibraryMaterial(LibraryMaterialCopy libraryMaterial)
   // default renewal method uses today's date as renewal date.
   {
       return renewLibraryMaterial(libraryMaterial, LocalDate.now());
   }

   public List<LibraryMaterialCopy> getlibraryMaterialsDueBy(LocalDate date)
   // returns an List of libraryMaterials due on or before date
   {
       List<LibraryMaterialCopy> libraryMaterialsDue = new ArrayList<LibraryMaterialCopy>();
       for (LibraryMaterialCopy libraryMaterial : libraryMaterialsCheckedOut) {
           if (libraryMaterial.getDueDate().isBefore(date) || libraryMaterial.getDueDate().equals(date)) {
               libraryMaterialsDue.add(libraryMaterial);
           }
       }

       return libraryMaterialsDue;
   }

   public List<LibraryMaterialCopy> getLibraryMaterialsOverdue(LocalDate todaysDate) {
       return getlibraryMaterialsDueBy(todaysDate.minusDays(1));
   }

   public List<LibraryMaterialCopy> getLibraryMaterialsOverdue()
   // default method, returns libraryMaterials overdue as of today, which means
   // that they
   // were due by yesterday
   {
       return getLibraryMaterialsOverdue(LocalDate.now());
   }

   public List<LibraryMaterialCopy> getLibraryMaterialsSorted()
   // returns List of libraryMaterials, sorted by due date (earliest due date
   // first)
   // uses insertion sort
   {
       List<LibraryMaterialCopy> libraryMaterials = new ArrayList<LibraryMaterialCopy>(libraryMaterialsCheckedOut);
       for (int i = 1; i < libraryMaterials.size(); i++) {
           int j = i;
           while (j > 0 && libraryMaterials.get(j - 1).getDueDate().isAfter(libraryMaterials.get(j).getDueDate())) {

               // swap elements in positions j and j-1
               LibraryMaterialCopy temp = libraryMaterials.get(j);
               libraryMaterials.set(j, libraryMaterials.get(j - 1));
               libraryMaterials.set(j - 1, temp);

               j = j - 1;
           }
       }
       return libraryMaterials;
   }
}

mainProgram.java


import java.util.ArrayList;
import java.util.List;
import java.time.LocalDate;

public class mainProgram {
   public static void main(String[] args) {
       ArrayList<LibraryMaterial> books = new ArrayList<LibraryMaterial>();
       books.add(new Book("12345678910", "Harry Potter", "J. K. Rowling"));
       books.add(new Book("98765432", "Berenstein Bears", "Stan and Jan"));
       books.add(new Book("6547901", "Curious George", "No Clue"));
       books.add(new Book("5678322222", "Samantha", "Me Myself"));

       ArrayList<LibraryMaterialCopy> bookCopies = new ArrayList<LibraryMaterialCopy>();
       for (LibraryMaterial b : books) {
           bookCopies.add(new BookCopy((Book) b));
       }

       ArrayList<LibraryCard> cards = new ArrayList<>();
       cards.add(new LibraryCard("123456", "Devorah Kletenik"));
       cards.add(new LibraryCard("87654", "Me and Me"));
       cards.add(new LibraryCard("8887654", "Sarah Kletenik"));

       for (LibraryMaterialCopy bc : bookCopies) {
           System.out.println(cards.get(0).checkOutLibraryMaterial(bc));
           System.out.println(cards.get(1).checkOutLibraryMaterial(bc));
           System.out.println(cards.get(2).checkOutLibraryMaterial(bc));
           System.out.println("Is Berenstein Bears title of the book:"+bc.isTitle("Berenstein Bears"));
       }

       List<LibraryMaterialCopy> bookCopies2 = cards.get(0).getLibraryMaterialsSorted();
       for (LibraryMaterialCopy book : bookCopies2)
           System.out.println(book.getTitle() + " " + book.getDueDate());

       System.out.println("got here");
       System.out.println(bookCopies.get(3).getTitle());
       ((BookCopy) bookCopies.get(3)).renew();

       System.out.println("renewed");

       bookCopies2 = cards.get(0).getLibraryMaterialsSorted();
       System.out.println("and here again");
       for (LibraryMaterialCopy book : bookCopies2)
           System.out.println(book.getTitle() + " " + book.getDueDate());

       System.out.println("here again");

       for (LibraryMaterialCopy bc : bookCopies) {
           System.out.println(cards.get(0).returnLibraryMaterial(bc));
           System.out.println(cards.get(1).returnLibraryMaterial(bc));
           System.out.println(cards.get(2).returnLibraryMaterial(bc));
       }

   }
}

Book.java


public class Book extends LibraryMaterial {
   private String author;

   public Book(String i, String t, String a) {
       super(i, t);
       author = a;
   }

   public String getAuthor() {
       return author;
   }

   public void print() {
       super.print();
       System.out.println("author: " + author);
   }
}

DVDCopy.java


public class DVDCopy extends LibraryMaterialCopy {
   public static final int BORROWING_WEEKS = 2;
   public static final double FINE_PER_DAY = 1;
   public static final boolean IS_RENEWABLE = false;
   private DVD dvd;

   public DVDCopy(DVD d) {
       super();
       dvd = d;
   }

   @Override
   public LibraryMaterial getLibraryMaterial() {
       return dvd;
   }

   @Override
   public String getTitle() {
       return dvd.getTitle();
   }

   @Override
   public String getISBN() {
       return dvd.getISBN();
   }

   public String getMainActor() {
       return dvd.getMainActor();
   }

   @Override
   public int getBorrowingWeeks() {
       return BORROWING_WEEKS;
   }

   @Override
   public double getFinePerDay() {
       return FINE_PER_DAY;
   }

   @Override
   public boolean isRenewable() {
       return IS_RENEWABLE;
   }

   public void print() {
       dvd.print();
       super.print();
   }

   @Override
   public boolean isTitle(String s) {
      
       if(this.dvd.getTitle().equals(s)) {
           return true;
       }
       return false;
   }
}

BookCopy.java


import java.time.*;

public class BookCopy extends LibraryMaterialCopy {
   private Book book;
   public static final int BORROWING_WEEKS = 3;
   public static final int RENEWAL_WEEKS = 2;
   public static final double FINE_PER_DAY = .10;
   public static final boolean IS_RENEWABLE = true;

   public BookCopy(Book b) {
       super();
       book = b;
   }

   @Override
   public LibraryMaterial getLibraryMaterial() {
       return book;
   }

   @Override
   public int getBorrowingWeeks() {
       return BORROWING_WEEKS;
   }

   @Override
   public double getFinePerDay() {
       return FINE_PER_DAY;
   }

   @Override
   public String getTitle() {
       return book.getTitle();
   }

   @Override
   public String getISBN() {
       return book.getISBN();
   }

   public String getAuthor() {
       return book.getAuthor();
   }

   @Override
   public boolean isRenewable() {
       return IS_RENEWABLE;
   }

   public boolean renew(LocalDate renewalDate) {
       if (card == null)
           return false;
       dueDate = renewalDate.plusWeeks(RENEWAL_WEEKS);
       return true;
   }

   public boolean renew()
   // default method uses todays date as renewal date
   {
       return renew(LocalDate.now());
   }

   public void print() {
       book.print();
       super.print();
   }

   @Override
   public boolean isTitle(String s) {

       if(this.book.getTitle().equals(s)) {
           return true;
       }
       return false;
   }
}

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


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;
   }
}

DVD.java


public class DVD extends LibraryMaterial {
   private String mainActor;

   public DVD(String i, String t, String mA) {
       super(i, t);
       mainActor = mA;
   }

   public String getMainActor() {
       return mainActor;
   }

   public void print() {
       super.print();
       System.out.println("Main actor: " + mainActor);
   }
}

Sample Output:

true

false

false

Is Berenstein Bears title of the book:false

true

false

false

Is Berenstein Bears title of the book:true

true

false

false

Is Berenstein Bears title of the book:false

true

false

false

Is Berenstein Bears title of the book:false

Harry Potter 2017-05-28

Berenstein Bears 2017-05-28

Curious George 2017-05-28

Samantha 2017-05-28

got here

Samantha

renewed

and here again

Samantha 2017-05-21

Harry Potter 2017-05-28

Berenstein Bears 2017-05-28

Curious George 2017-05-28

here again

true

false

false

true

false

false

true

false

false

true

false

false

Add a comment
Know the answer?
Add Answer to:
Modify the library program as follows: Create a method in the LibraryMaterial class that accepts a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • this needs to be in Java: use a comparator class which is passed into the sort...

    this needs to be in Java: use a comparator class which is passed into the sort method that is available on the ArrayList. import java.util.Scanner; public class Assign1{ public static void main(String[] args){ Scanner reader = new Scanner (System.in); MyDate todayDate = new MyDate(); int choice = 0; Library library = new Library(); while (choice != 6){ displayMainMenu(); if (reader.hasNextInt()){ choice = reader.nextInt(); switch(choice){ case 1: library.inputResource(reader, todayDate); break; case 2: System.out.println(library.resourcesOverDue(todayDate)); break; case 3: System.out.println(library.toString()); break; case 4: library.deleteResource(reader,...

  • How to solve and code the following requirements (below) using the JAVA program? 1. Modify the...

    How to solve and code the following requirements (below) using the JAVA program? 1. Modify the FoodProduct Class to implement Edible, add the @Overrride before any methods that were there (get/set methods) that are also in the Edible interface. 2. Modify the CleaningProduct Class to implement Chemical, add the @Overrride before any methods that were there (get/set methods) that are also in the Chemical interface. 3. Create main class to read products from a file, instantiate them, load them into...

  • Can anyone helps to create a Test.java for the following classes please? Where the Test.java will...

    Can anyone helps to create a Test.java for the following classes please? Where the Test.java will have a Scanner roster = new Scanner(new FileReader(“roster.txt”); will be needed in this main method to read the roster.txt. public interface List {    public int size();    public boolean isEmpty();    public Object get(int i) throws OutOfRangeException;    public void set(int i, Object e) throws OutOfRangeException;    public void add(int i, Object e) throws OutOfRangeException; public Object remove(int i) throws OutOfRangeException;    } public class ArrayList implements List {   ...

  • I've previously completed a Java assignment where I wrote a program that reads a given text...

    I've previously completed a Java assignment where I wrote a program that reads a given text file and creates an index that stores the line numbers for where individual words occur. I've been given a new assignment where I need to modify some of my old code. I need to replace the indexer in my Index class with a NavigableMap<String, Word> and update my Word class with NavigableSet<Integer> lines. The instantiated objects should be TreeMap() and TreeSet(). I have below...

  • How to build Java test class? I am supposed to create both a recipe class, and...

    How to build Java test class? I am supposed to create both a recipe class, and then a class tester to test the recipe class. Below is what I have for the recipe class, but I have no idea what/or how I am supposed to go about creating the test class. Am I supposed to somehow call the recipe class within the test class? if so, how? Thanks in advance! This is my recipe class: package steppingstone5_recipe; /** * *...

  • Consider the Automobile class: public class Automobile {    private String model;    private int rating;...

    Consider the Automobile class: public class Automobile {    private String model;    private int rating; // a number 1, 2, 3, 4, 5    private boolean isTruck;    public Automobile(String model, boolean isTruck) {       this.model = model;       this.rating = 0; // unrated       this.isTruck = isTruck;    }        public Automobile(String model, int rating, boolean isTruck) {       this.model = model;       this.rating = rating;       this.isTruck = isTruck;    }                public String getModel()...

  • java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and sh...

    java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and short by name, course, instructor, and location. ///main public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Student>students = new ArrayList<>(); int choice; while(true) { displayMenu(); choice = in.nextInt(); switch(choice) { case 1: in.nextLine(); System.out.println("Enter Student Name"); String name...

  • FOR JAVA: Summary: Create a program that adds students to the class list (see below). The...

    FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...

  • complete this in java import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class...

    complete this in java import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class WordDetective { /** * Picks the first unguessed word to show. * Updates the guessed array indicating the selected word is shown. * * @param wordSet The set of words. * @param guessed Whether a word has been guessed. * @return The word to show or null if all have been guessed. */    public static String pickWordToShow(ArrayList<String> wordSet, boolean []guessed) { return null;...

  • import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; public class FindWordInMaze { private char grid[][]; private...

    import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; public class FindWordInMaze { private char grid[][]; private ArrayList<String> words; private HashSet<String> foundWords = new HashSet<String>(); public FindWordInMaze(char[][] grid) { this.grid = grid; this.words = new ArrayList<>();    // add dictionary words words.add("START"); words.add("NOTE"); words.add("SAND"); words.add("STONED");    Collections.sort(words); } public void findWords() { for(int i=0; i<grid.length; i++) { for(int j=0; j<grid[i].length; j++) { findWordsFromLocation(i, j); } }    for(String w: foundWords) { System.out.println(w); } } private boolean isValidIndex(int i, int j, boolean visited[][]) { return...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT