|
@@ -15,7 +15,7 @@ public class PhoneBook {
|
15
|
15
|
PhoneBook myPhoneBookActualObjectInstance= new PhoneBook();
|
16
|
16
|
myPhoneBookActualObjectInstance.add("vince", "1123456789");
|
17
|
17
|
myPhoneBookActualObjectInstance.add("amy", "29387429");
|
18
|
|
- System.out.println(myPhoneBookActualObjectInstance.showNames());
|
|
18
|
+ System.out.println(myPhoneBookActualObjectInstance.displayEntirePhoneBookContents());
|
19
|
19
|
}
|
20
|
20
|
|
21
|
21
|
|
|
@@ -45,15 +45,33 @@ public class PhoneBook {
|
45
|
45
|
|
46
|
46
|
}
|
47
|
47
|
|
48
|
|
- public String showNames() {
|
|
48
|
+ public String reverseLookup(String number) {
|
49
|
49
|
|
50
|
|
- String phoneList = "";
|
51
|
|
- Set<String> unsortedKeys = personTreeMap.keySet();
|
52
|
|
- for (String personsName : unsortedKeys) {
|
53
|
|
- phoneList += (personsName + "\n");
|
|
50
|
+ return
|
|
51
|
+
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ public String showNamesOnly() {
|
|
55
|
+
|
|
56
|
+ String phoneListOfNamesOnly= "";
|
|
57
|
+ Set<String> nameTreeKeys = personTreeMap.keySet();
|
|
58
|
+ for (String personsName : nameTreeKeys) {
|
|
59
|
+ phoneListOfNamesOnly += (personsName + "\n");
|
54
|
60
|
}
|
55
|
61
|
|
56
|
|
- return phoneList;
|
|
62
|
+ return phoneListOfNamesOnly;
|
|
63
|
+
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ public String displayEntirePhoneBookContents() {
|
|
67
|
+
|
|
68
|
+ String entirePhoneBook = "";
|
|
69
|
+ Set<String> nameTreeKeys = personTreeMap.keySet();
|
|
70
|
+ for (String personsName : nameTreeKeys) {
|
|
71
|
+ entirePhoneBook += (personsName + "'s phone number: " + personTreeMap.get(personsName).getNumbers() + "\n");
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ return entirePhoneBook;
|
57
|
75
|
|
58
|
76
|
}
|
59
|
77
|
|