Browse Source

more additions

Amy Gill 6 years ago
parent
commit
852188ccd2

+ 8
- 0
src/main/java/com/zipcodewilmington/phonebook/Person.java View File

@@ -26,6 +26,14 @@ public class Person {
26 26
     public String getNumbers(){
27 27
         return phoneNumber.toString();
28 28
     }
29
+
30
+    public void removeSingleNumber (String number){
31
+        phoneNumber.remove(number);
32
+    }
33
+
34
+    public void addAdditionalNumber(String number){
35
+        phoneNumber.add(number);
36
+    }
29 37
 }
30 38
 
31 39
 

+ 2
- 1
src/main/java/com/zipcodewilmington/phonebook/PhoneBook.java View File

@@ -15,6 +15,7 @@ public class PhoneBook {
15 15
         PhoneBook myPhoneBookActualObjectInstance= new PhoneBook();
16 16
         myPhoneBookActualObjectInstance.add("vince", "1123456789");
17 17
         myPhoneBookActualObjectInstance.add("amy", "29387429");
18
+        myPhoneBookActualObjectInstance.personTreeMap.get("amy").addAdditionalNumber("2344");
18 19
         System.out.println(myPhoneBookActualObjectInstance.displayEntirePhoneBookContents());
19 20
     }
20 21
 
@@ -34,7 +35,7 @@ public class PhoneBook {
34 35
     }
35 36
 
36 37
 
37
-    public void remove(String name) {
38
+    public void removeEntireEntry (String name) {
38 39
 
39 40
         personTreeMap.remove(name);
40 41
     }

+ 27
- 5
src/test/java/com/zipcodewilmington/phonebook/PhoneBookTest.java View File

@@ -12,26 +12,48 @@ import java.util.TreeMap;
12 12
  */
13 13
 public class PhoneBookTest {
14 14
 
15
-    PhoneBook testPhonebook = new PhoneBook();
15
+//Start off here. google "how to write a test for a map"
16
+//    PhoneBook testPhonebook = new PhoneBook(); <=why didn't this work?
17
+    PhoneBook testPhonebook;
16 18
 
17 19
     @Before
20
+    public void setup() {
21
+            testPhonebook = new PhoneBook();
22
+    }
18 23
 
19
-    public void setup(){
20
-
21
-//Start off here. google "how to write a test for a map"
24
+    @Test
25
+    public void addEntryTestCase1(){
26
+        new Person("Addison", "1234");
27
+        testPhonebook.add("Addison", "1234");
28
+        String testNumber = testPhonebook.lookup("Addison");
29
+        Assert.assertTrue(testNumber.equals("[1234]"));
30
+    }
22 31
 
32
+    @Test
33
+    public void addEntryTestCase2(){
34
+        new Person("AdDy", "123.4");
35
+        testPhonebook.add("AdDy", "123.4");
36
+        String testNumber = testPhonebook.lookup("AdDy");
37
+        Assert.assertTrue(testNumber.equals("[123.4]"));
23 38
     }
24 39
 
40
+
41
+
25 42
     @Test
26 43
     public void testLookup() {
27 44
 
28 45
         testPhonebook.add("JohnDoe", "1123");
29 46
 
30
-        String expected = "1123";
47
+        String expected = "[1123]";
31 48
         String actual = testPhonebook.lookup("JohnDoe");
32 49
 
33 50
         Assert.assertEquals(expected, actual);
34 51
 
35 52
     }
36 53
 
54
+    @Test
55
+    public void test (){
56
+
57
+    }
58
+
37 59
 }