Question: QUESTION 10 The class Library, outlined below, uses a HashSet to manage a collection of Books. The public methods of this class are given and

 QUESTION 10 The class Library, outlined below, uses a HashSet to

QUESTION 10 The class Library, outlined below, uses a HashSet to manage a collection of Books. The public methods of this class are given and your task is to write the code for each of these. The description of the task for each method is described as a comment in the code below. (Class Book is described in Question 9 above and you may assume that class Book has an equals and a hashCode method) class Library{ private HashSet data = new HashSet>(); public void add(Book c)(data.add(c);} public boolean search(Book cX//search for Book c} (2 marks) public Book get(String rX //return reference to first Book that has title equal to r } (3 marks) public int count({ 1/Get the amount of books in Library } (3 marks) public void addBooks(HashSet set) //add the collection of Books to data } (2 marks) } (See Appendix A for a description of Set methods). Total (10 marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!