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

Need help with coding. I am stuck on an add function. It asked us to test whethe

ID: 3904308 • Letter: N

Question

Need help with coding. I am stuck on an add function. It asked us to test whether can we add a book to the set. Here is my code:

Here is the test code:

And here is the constructor:

public class BookSet implements Set<Book>{

private Book[] books;

public BookSet() {

       books = new Book[8];

   }

public BookSet(Book[] books) {

       this.books = books;

}

sò a * Adds the specified book to the set * this method returns true if the BookSet was modified * When you run out of space in the Books Array, please use the * extendArray method * to increase the size of the Array o A set can only contain one copy of a Book, so do NOT add duplicates * and return false in this case * @see java.util.Set#add(java.lang. Object) 89 900 ô Ô O OOOO @Overridel public boolean add(Book arg0) { Book [] adds = new Book [8]; BookSet bookAdds = new BookSetCadds); for(int i = 0; i

Explanation / Answer

@Override public boolean add(Book arg0) { int size = size(); for(int i = 0; i