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

Thread: phone book with linked list?

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default phone book with linked list?

    Can somebody tell me how i combine this to classes then make a client?
    The class PhoneBook is gonna use methods from linked list class. Just show me example how to combine and how to use methods from linked list class.

    public class EntryNumber implements Comparable<EntryNumber> {
    private String number, name;

    public EntryNumber(){
    this("", "");
    }

    public EntryNumber(String number, String name){
    setNumber(number);
    setName(name);
    }

    public String getNumber(){
    return number;
    }

    public String getName(){
    return name;
    }

    public void setNumber(String number){
    this.number = number;
    }

    public void setName(String name){
    this.name = name;
    }

    public String toString(){
    return number.toString() + name.toString();
    }

    public boolean equals(Object obj){
    return getNumber().equals(((EntryNumber) obj).getNumber());
    }

    @Override
    public int compareTo(EntryNumber number) {
    return getNumber().compareTo(number.getNumber());
    }

    public class PhoneBook {

    private List<EntryNumber> b;

    public PhoneBook(){
    }

    public void insert(EntryNumber number) {

    }

    public void insert(String number, String name){

    }

    public String findNumber(String number){
    return number;
    }

    public String findName(String name){
    return name;
    }


    public boolean remove(EntryNumber entrynumber){

    }

    public List<EntryNumber> getAll(){
    }

    public int numberOfNumbers(){
    }

    public String toString(){
    return b.toString();
    }



    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: phone book with linked list?

    Huh? What's your question? What have you tried? Where exactly are you stuck? I don't see any code there that's using a LinkedList. Is this a homework assignment by any chance?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: phone book with linked list?

    Yes it is homework assignment. It stands that the phonebook is a linked list and that the phonebook class need to use linked list class methods.
    Can you show me how to use linked list methods into the phonebook and how to instance phonebook class into a client program?

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: phone book with linked list?

    Quote Originally Posted by osloboy28 View Post
    Yes it is homework assignment. It stands that the phonebook is a linked list and that the phonebook class need to use linked list class methods.
    Can you show me how to use linked list methods into the phonebook and how to instance phonebook class into a client program?
    I'm sorry, but what you're saying just doesn't make a ton of sense to me. For example, what does "to instance phonebook class into a client program" mean?

    Have you checked out the API for LinkedList?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. The Following User Says Thank You to KevinWorkman For This Useful Post:

    osloboy28 (September 7th, 2011)

  6. #5
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: phone book with linked list?

    I have checked it out but i dont understand how to use Linked list to make a phonebook with the to classes. Thanks for trying to understand. I will figure it out in school.

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: phone book with linked list?

    Why do you think a linked list is a good way to store phone number information?
    How are you going to use the data in the list? Will there be lots of changes to the list?
    Or will the contents of the list stay relatively unchanged?

Similar Threads

  1. linked list help
    By tjoney in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 3rd, 2011, 06:54 PM
  2. [SOLVED] Linked List Help
    By lieles in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 4th, 2011, 10:32 PM
  3. phone book code problems
    By mu'min in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 16th, 2010, 11:36 AM
  4. phone book code problems
    By mu'min in forum Member Introductions
    Replies: 1
    Last Post: December 16th, 2010, 09:07 AM
  5. phone book
    By Skat in forum What's Wrong With My Code?
    Replies: 14
    Last Post: December 3rd, 2010, 09:56 AM

Tags for this Thread