Hi, I've found this exercise at the end my textbook and have been trying to solve it but I 'm absolutely stuck.
I'm not good at programming with java and would like some help to understand how to implement the necessary code for this program. I would greatly appreciate it because it would help me understand my programming course at school a lot better
Create the BookHashTable class that will store the books in a table using the modHash hashing function (setting max to the array capacity) and using linked lists for collision resolution. Your class should include the following:
A protected class HashNode that will have two data members: - data which is a Book object
- link which is a HashNode object
The data members for BookHashTable are: - A private static constant for the default size of the table to be 10 - An array of HashNode objects
The methods to manipulate a BookHashTable object will be: public BookHashTable():constructor that instantiates an array of the default size and initializes all elements to null.
public BookHashTable(int sz):theone-parameterconstructortoinstantiateanarrayofthegiven sizeandinitialize all elements to null.
private int hashFunction ( String number ) : private method that will be given a book number and return the result of the hash function ( index value )... use the modHash function from the slides with max= the default size of the table.
public boolean addBook ( Book newBook ) : method to add a new book to the table. It returns true if the book was added and false otherwise (book number already in the table ). Include a System.out.println in the method to output the book number and the corresponding result of the hashing function ( index value in the table ).
public BookClass findBook (String number) : method that will return a Book object if it is found in the table and return null otherwise.
public boolean deleteBook (String number): method to remove a book from the table. It returns true if the book was deleted from the table and false otherwise (book number not in the table )
public String toString () : returns a string containing all the books in no particular order. BONUS: ass a copy constructor.
Re: Assignment problem.
What are your thoughts on how to implement this?
If you're unsure on where to get started, I would recommend reading through your textbook on different components of the Java syntax (methods, variables, data types, conditionals and loops, etc.). Another good source are the The Java™ Tutorials by Sun Oracle (or is it just Oracle now?).