Katrice Williams-Dredden 6 years ago
parent
commit
fad1f01d48

+ 35
- 7
src/main/java/com/zipcodewilmington/phonebook/Person.java View File

@@ -1,21 +1,49 @@
1 1
 package com.zipcodewilmington.phonebook;
2
+import java.util.ArrayList;
2 3
 
3 4
 //the class
4 5
 public class Person {
5 6
     private String name;
6
-    private String number;
7
-
8
-    public Person(String name, String number){
7
+    private ArrayList<String> phonenumbers;
8
+    //person constructor
9
+    //for each person you make the number will go into the array list
10
+    public Person(String name, String numbers){
9 11
         this.name = name;
10
-        this.number = number;
11
-
12
+        this.phonenumbers = new ArrayList<String>();
13
+        phonenumbers.add(numbers);
12 14
     }
15
+
13 16
     //creating get methods
14 17
     public String getName() {
15 18
         return name;
16 19
     }
20
+    //iterate through the ArrayList and add each one to a string
21
+    public ArrayList<String> getPhoneNumbers() {
22
+        return phonenumbers;
23
+    }
24
+
25
+//just add your parameter to the existing ArrayList
26
+    public void setAddAdditionalNumber(String numbers){
17 27
 
18
-    public String getNumber() {
19
-        return number;
20 28
     }
29
+
30
+    /* public void setUpdateName(String name){
31
+
32
+    }
33
+
34
+    public void setUpdateNumber(String number){
35
+
36
+    }*/
37
+
38
+   /* public String getUpdateName(){
39
+        return null;
40
+    }
41
+
42
+    public String getUpdateNumber(){
43
+        return null;
44
+    }*/
45
+/*
46
+    public String getAddAdditionalNumber(){
47
+        return null;
48
+    }*/
21 49
 }

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

@@ -9,9 +9,10 @@ import java.util.TreeMap;
9 9
  */
10 10
 //the class
11 11
 public class PhoneBook {
12
-
12
+    //constructor
13 13
     public PhoneBook(){
14
-        TreeMap<String, String>entry = new TreeMap();
14
+        //this is saying that the treemap is going to have the string as a key and the Person as the value
15
+        TreeMap<String, Person> entry = new TreeMap();
15 16
     }
16 17
 
17 18
 

+ 17
- 7
src/test/java/com/zipcodewilmington/phonebook/TestPerson.java View File

@@ -1,21 +1,21 @@
1 1
 package com.zipcodewilmington.phonebook;
2 2
 
3
-
3
+import java.util.ArrayList;
4 4
 import org.junit.Assert;
5 5
 import org.junit.Test;
6 6
 
7 7
 public class TestPerson {
8 8
 
9
-    @Test
10
-
11 9
 
12 10
 
13 11
 
14 12
 
15 13
     @Test
16 14
     public void testGetName() {
17
-        Person person = new Person("Nathaniel", "8567744773");
15
+        //we place the expected on top
18 16
         String expected = "Nathaniel";
17
+        Person person = new Person("Nathaniel", expected);
18
+
19 19
 
20 20
         //I don't need a setter, because i did "this.name"...remember
21 21
         String actual = person.getName();
@@ -24,16 +24,26 @@ public class TestPerson {
24 24
     }
25 25
 
26 26
     @Test
27
-    public void testGetNumber(){
28
-        Person person = new Person("Nathaniel", "8567744773");
27
+    public void testGetPhoneNumbers(){
29 28
         String expected = "8567744773";
29
+        Person person = new Person("Nathaniel",expected);
30
+
30 31
 
31
-        String actual = person.getNumber();
32
+        ArrayList<String> actual = person.getPhoneNumbers();
32 33
         Assert.assertEquals(expected, actual);
33 34
     }
34 35
 
36
+    @Test
37
+    public void testSetAddAdditionalNumbers(){
38
+        //Given
39
+        String expected = "Karen";
40
+
41
+        //When
42
+        person.setPhoneNumbers(expected);
35 43
 
36 44
 
45
+    }
46
+
37 47
 
38 48
 
39 49