1 57 58 package addressbook.wsiftypes; 59 60 import java.util.*; 61 import org.w3c.dom.*; 62 import javax.xml.parsers.*; 63 64 import addressbook.wsiftypes.*; 65 66 72 public class AddressBook { 73 private HashMap name2AddressTable = new HashMap(); 74 75 public AddressBook() { 76 addEntry("John B. Good", 77 new Address(123, "Main Street", "Anytown", "NY", 12345, 78 new Phone(123, "456", "7890"))); 79 addEntry("Bob Q. Public", 80 new Address(456, "North Whatever", "Notown", "ME", 12424, 81 new Phone(987, "444", "5566"))); 82 } 83 84 public void addEntry(String name, Address address) 85 { 86 name2AddressTable.put(name, address); 87 } 88 89 public void addEntry(String firstName, String lastName, Address address) 90 { 91 name2AddressTable.put(firstName+" "+lastName, address); 92 } 93 94 public Address getAddressFromName(String name) 95 throws IllegalArgumentException 96 { 97 return (Address)name2AddressTable.get(name); 98 } 99 100 } 101 102 | Popular Tags |