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

I need to create an addLibrary method for my array of objects Tune Suppose I dec

ID: 3649152 • Letter: I

Question

I need to create an addLibrary method for my array of objects Tune
Suppose I declare Library music1 and Library music2.
If my library music1 has 10 tunes (Tune array[10]) I need to add those tunes to my other array of tunes (music2).

This is what addLibrary should do:
public void addLibrary(Library l) : adds all books from the given Library, or prints out an error message saying "The library is full" for each book that cannot be added because the array is already full

For that purpose I have already created the method addBook(Book b)
public void addBook(Book b)
{
//check if program can add new book

if(count < array.length)
{
array[count] = b;
count++;

}
else
{
System.out.println("The Library is full!");
}

}


Explanation / Answer

You have to check whether you have declared your variables globally or locally, if locally check whether they are accessible from where you are calling them. public void addLibrary(Library l) { for(int i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote