Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
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; iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started