|
@@ -57,17 +57,30 @@ public class PhoneBook {
|
57
|
57
|
|
58
|
58
|
public String listPhoneBook() {
|
59
|
59
|
|
|
60
|
+ StringBuilder printBook = new StringBuilder();
|
60
|
61
|
|
61
|
|
- String allInfo = "";
|
|
62
|
+ for (Map.Entry<String, String> entry : myTree.entrySet()) {
|
|
63
|
+ String key = entry.getKey();
|
|
64
|
+ String value = entry.getValue();
|
62
|
65
|
|
63
|
|
- for (Map.Entry<String, String> entry: myTree.entrySet()){
|
64
|
|
- String getKeys = String.format("%1$-15s", entry.getKey());
|
65
|
|
- String getValues = String.format("%1$-15s", entry.getValue());
|
|
66
|
+ printBook.append(key).append(" = ").append(value).append("\n");
|
66
|
67
|
|
67
|
|
- allInfo += getKeys + getValues + "\n";
|
|
68
|
+// String allInfo = "";
|
|
69
|
+//
|
|
70
|
+// for (Map.Entry<String, String> entry: myTree.entrySet()){
|
|
71
|
+// String getKeys = String.format("%1$-15s", entry.getKey());
|
|
72
|
+// String getValues = String.format("%1$-15s", entry.getValue());
|
|
73
|
+//
|
|
74
|
+// allInfo += getKeys + getValues + "\n";
|
68
|
75
|
}
|
|
76
|
+ String result = printBook.toString();
|
69
|
77
|
|
70
|
|
- return allInfo;
|
|
78
|
+ return result;
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ public String reverseLookup() {
|
|
82
|
+
|
|
83
|
+ return null;
|
71
|
84
|
}
|
72
|
85
|
|
73
|
86
|
|