Build a simple PhoneBook program.

PhoneBook.java 527B

123456789101112131415161718192021222324252627
  1. import java.util.TreeMap;
  2. import java.util.Map;
  3. import java.util.ArrayList;
  4. /**
  5. * Created by leon on 1/23/18.
  6. */
  7. public class PhoneBook {
  8. Map<String,Entry> phonebook = new TreeMap<String,Entry>();
  9. public PhoneBook(){
  10. }
  11. public void addEntry(String name, String phoneNumber){
  12. Entry newEntry = new Entry(phoneNumber);
  13. phonebook.put(name,newEntry);
  14. }
  15. public Entry getEntry(String name){
  16. return phonebook.get(name);
  17. }
  18. }