|
@@ -27,7 +27,6 @@ public PhoneBook() {
|
27
|
27
|
|
28
|
28
|
public String lookup(String name){
|
29
|
29
|
return contacts.get(name);
|
30
|
|
-
|
31
|
30
|
}
|
32
|
31
|
|
33
|
32
|
public String listNames(){
|
|
@@ -46,13 +45,23 @@ public PhoneBook() {
|
46
|
45
|
StringBuilder namesnumbers = new StringBuilder();
|
47
|
46
|
Set<String> keys = contacts.keySet();
|
48
|
47
|
for(String key: keys)
|
49
|
|
-
|
50
|
48
|
{
|
51
|
|
-
|
52
|
49
|
namesnumbers.append(key+" "+contacts.get(key)+"\n");
|
53
|
50
|
}
|
54
|
51
|
return namesnumbers.toString();
|
55
|
52
|
}
|
56
|
53
|
|
|
54
|
+ public String reverselookup(String number){
|
|
55
|
+ Set<String> names = contacts.keySet();
|
|
56
|
+ for(String name: names)
|
|
57
|
+ {
|
|
58
|
+ if (contacts.get(name).equals(number)){
|
|
59
|
+ return name;
|
|
60
|
+ }
|
|
61
|
+ }
|
|
62
|
+ return null;
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+
|
57
|
66
|
|
58
|
67
|
}
|