Browse Source

All tests work and I am focusing on People class

Daniel Horowitz 6 years ago
parent
commit
1202a44bf7

+ 3
- 4
src/main/java/com/zipcodewilmington/phonebook/PhoneBook.java View File

@@ -10,13 +10,12 @@ import java.util.*;
10 10
 public class PhoneBook {
11 11
 
12 12
     private String name;
13
-    private String number;
13
+    private ArrayList<String> number;
14 14
 
15 15
     TreeMap<String, ArrayList<String>> myTree = new TreeMap<String, ArrayList<String>>();
16 16
 
17 17
 
18 18
     public PhoneBook(){
19
-
20 19
     }
21 20
 
22 21
 
@@ -33,8 +32,8 @@ public class PhoneBook {
33 32
 
34 33
 
35 34
     public void removeNumberFromName(String name, String number) {
36
-
37
-        myTree.get(name).remove(number);
35
+        List<String> phoneNumbers = myTree.get(name);
36
+        phoneNumbers.remove(number);
38 37
     }
39 38
 
40 39
 

+ 13
- 4
src/test/java/com/zipcodewilmington/phonebook/PhoneBookTest.java View File

@@ -18,9 +18,9 @@ public class PhoneBookTest {
18 18
     @Test
19 19
     public void addTest() {
20 20
         PhoneBook testBook = new PhoneBook();
21
-        testBook.addEntry("Luke", "6109998787");
22
-        String testNumber = testBook.lookupNumber("Luke");
23
-        Assert.assertTrue(testNumber.equals("6109998787,"));
21
+        testBook.addEntry("Joe", "1234567", "2345678");
22
+        String testNumber = testBook.lookupNumber("Joe");
23
+        Assert.assertTrue(testNumber.equals("1234567, 2345678,"));
24 24
 
25 25
     }
26 26
 
@@ -89,7 +89,16 @@ public class PhoneBookTest {
89 89
 
90 90
     }
91 91
 
92
-
92
+    @Test
93
+    public void RemoveNumberFromNameTest(){
94
+        PhoneBook testBook = new PhoneBook();
95
+        testBook.addEntry("Adam", "4864569090", "7879891212");
96
+        testBook.removeNumberFromName("Adam", "4864569090");
97
+        String expected = "7879891212,";
98
+        String actual = testBook.lookupNumber("Adam");
99
+        System.out.println(actual);
100
+        Assert.assertTrue(expected.equals(actual));
101
+    }
93 102
 
94 103
     @Test
95 104
     public void additionalPhoneNumberToKeyTest() {