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();
}
}
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?
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?
Re: phone book with linked list?
Quote:
Originally Posted by
osloboy28
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?
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. ;)
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?