|
|
|
|
14
|
|
14
|
|
15
|
### Part I:
|
15
|
### Part I:
|
16
|
|
16
|
|
17
|
-Create a PhoneBook class that holds names and phone numbers. You can use an associative data type (one which stores items as keys paired with values).
|
|
|
|
|
17
|
+Create a PhoneBook class that holds names and phone numbers. You can use an associative data type (one which stores items as keys paired with values). (Hint: You should use a sorted map).
|
18
|
|
18
|
|
19
|
Your PhoneBook class should have the following method
|
19
|
Your PhoneBook class should have the following method
|
20
|
* lookup(String name) - allows you to look up a person's phone number based on their name
|
20
|
* lookup(String name) - allows you to look up a person's phone number based on their name
|
|
|
|
|
22
|
* remove(String name) - remove entry
|
22
|
* remove(String name) - remove entry
|
23
|
* display() - list all entries (names an phone numbers) in alphabetical order
|
23
|
* display() - list all entries (names an phone numbers) in alphabetical order
|
24
|
|
24
|
|
|
|
25
|
+ ```java
|
|
|
26
|
+ PhoneBook phoneBook = new PhoneBook();
|
|
|
27
|
+ phoneBook.add("Zebra", "111-222-333");
|
|
|
28
|
+ phoneBook.add("Dog", "222-444-4444");
|
|
|
29
|
+ phoneBook.display();
|
|
|
30
|
+
|
|
|
31
|
+ /*
|
|
|
32
|
+ Calling display this should print out the entries like this
|
|
|
33
|
+ Dog 222-444-4444
|
|
|
34
|
+ Zebra 111-222-333
|
|
|
35
|
+ */
|
|
|
36
|
+
|
|
|
37
|
+ ```
|
|
|
38
|
+
|
25
|
### Part II:
|
39
|
### Part II:
|
26
|
|
40
|
|
27
|
Add a `reverseLookup()` method to PhoneBook. This method should allow you to look up names by the phone number associated with them.
|
41
|
Add a `reverseLookup()` method to PhoneBook. This method should allow you to look up names by the phone number associated with them.
|