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 3 of 3

Thread: Interface task

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Interface task

    Write an interface Directory to manipulate entries in a telephone directory for the
    University. The interface must support the following operations:

    1) The ability to insert new entries into the directory. Entries should be stored in
    alphabetical order of surname.
    2) Delete entries from the directory either by name or number
    3) Provide a lookup method that will find the extension no of a member of staff given
    his/her name. You should try to make this method run as efficiently as possible.
    4) Change a person’s telephone number
    5) Print the telephone directory in a neatly tabulated fashion.

    Write a class ArrayDirectory that implements this interface using an array to store the
    telephone directory information. The class must store the surname and initial for each
    member of staff and their telephone extension (a four digit number which may start with a
    zero). You may find it useful to define a class Entry to store information about individual
    entries. The entries should be read into the array from a text file consisting of multiple lines
    in the following format:

    Surname<tab>Initials<tab>Telephone extension

    Write a main program that reads in data from a file and then tests all the methods of your
    class interface. Note it is not necessary to write data back to disk (even if it has changed) in
    this project.

    For data insertion and lookup, you should measure the performance for the average case (e.g.
    looking up a record in the middle of the data). To do this you can use the static method
    System.currentTimeMillis() which returns the time in milliseconds. To get an
    accurate measure of the time to perform an operation it is a good idea to perform each
    operation 1000 (or even 10000) times and measure the time taken. This will remove any problems due to the system clock having a coarse granularity (not ticking very often).
    Make sure you only time the method and not any input/output associated with it. Your
    documentation should include a discussion of these results.

    Part 2

    You decide that your solution to part 1 may be too slow to be useful when used with a real
    large telephone directory and make the following changes to attempt to improve the
    performance of your program:

    1). Provide a second implementation (ListDirectory) of the Directory interface
    using the Java Collections List interface and LinkedList classes.
    2). The changes in 1) should make adding, deleting and modifying records more efficient
    but will probably reduce the time to lookup numbers. To overcome this you use a technique
    called hashing. Instead of storing all the records on one list you use a series of lists. The data
    for all people whose surname begins with ‘A’ is stored on the first list, records for all people
    whose surname begins with ‘B’ on a second list and so on. Write a third implementation
    (HashDirectory) of the Directory interface using this technique.

    Again, you should measure the performance for the best, worst and average cases of
    implementations 1) and 2) above. Compare the efficiency of each of the 3 implementations in
    your documentation.

    Part 3

    Choose one of your 3 implementations from Parts 1 and 2 and embed it in a graphical user
    interface that allows users to perform all the methods in the Directory interface using a mouse
    and keyboard appropriately.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Interface task

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers.

    What you've posted is known as a "homework dump." If you do not exhibit some effort and/or ask specific questions (Please, something other than "I don't know where to start.") about what you need help with, this thread will be locked, and you will be invited to try again.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Interface task

    Thread closed.

Similar Threads

  1. Need help with home task.
    By clyxee in forum Totally Off Topic
    Replies: 2
    Last Post: December 6th, 2013, 03:26 AM
  2. how to assign different task to different threads
    By pratapak81 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 19th, 2013, 07:15 AM
  3. Java Task
    By frictionmind in forum Java Theory & Questions
    Replies: 0
    Last Post: July 21st, 2013, 01:12 PM
  4. Need Help With My Task
    By pumpkins in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 24th, 2013, 04:02 AM
  5. task manager
    By sayed shah in forum Object Oriented Programming
    Replies: 1
    Last Post: April 27th, 2012, 04:15 PM