Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Assignment problem.

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Assignment problem.

    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.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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?).

Similar Threads

  1. please help me in my assignment :(
    By asdfg in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 18th, 2010, 07:59 AM
  2. need help on an assignment :(
    By gamfreak in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 23rd, 2010, 04:20 PM
  3. Replies: 1
    Last Post: February 22nd, 2010, 08:20 AM
  4. Need help with assignment
    By TonyL in forum Loops & Control Statements
    Replies: 2
    Last Post: February 20th, 2010, 09:44 PM
  5. [SOLVED] "GridLayout" problem in Java program
    By antitru5t in forum AWT / Java Swing
    Replies: 3
    Last Post: April 16th, 2009, 10:26 AM