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
 public class PhoneBook {
10
 public class PhoneBook {
11
 
11
 
12
     private String name;
12
     private String name;
13
-    private String number;
13
+    private ArrayList<String> number;
14
 
14
 
15
     TreeMap<String, ArrayList<String>> myTree = new TreeMap<String, ArrayList<String>>();
15
     TreeMap<String, ArrayList<String>> myTree = new TreeMap<String, ArrayList<String>>();
16
 
16
 
17
 
17
 
18
     public PhoneBook(){
18
     public PhoneBook(){
19
-
20
     }
19
     }
21
 
20
 
22
 
21
 
33
 
32
 
34
 
33
 
35
     public void removeNumberFromName(String name, String number) {
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
     @Test
18
     @Test
19
     public void addTest() {
19
     public void addTest() {
20
         PhoneBook testBook = new PhoneBook();
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
 
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
     @Test
103
     @Test
95
     public void additionalPhoneNumberToKeyTest() {
104
     public void additionalPhoneNumberToKeyTest() {