Browse Source

Merge fad1f01d4882a244f958602c967bb440bfe36645 into 74a9673e36c7d25c28315cb54247a91792f8fbc0

Katrice 6 years ago
parent
commit
c9831d0db6
No account linked to committer's email

+ 7
- 1
pom.xml View File

@@ -7,6 +7,12 @@
7 7
     <groupId>com.zipcodewilmington</groupId>
8 8
     <artifactId>phonebok</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
-
10
+    <dependencies>
11
+        <dependency>
12
+            <groupId>junit</groupId>
13
+            <artifactId>junit</artifactId>
14
+            <version>RELEASE</version>
15
+        </dependency>
16
+    </dependencies>
11 17
 
12 18
 </project>

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

@@ -0,0 +1,49 @@
1
+package com.zipcodewilmington.phonebook;
2
+import java.util.ArrayList;
3
+
4
+//the class
5
+public class Person {
6
+    private String name;
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){
11
+        this.name = name;
12
+        this.phonenumbers = new ArrayList<String>();
13
+        phonenumbers.add(numbers);
14
+    }
15
+
16
+    //creating get methods
17
+    public String getName() {
18
+        return name;
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){
27
+
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
+    }*/
49
+}

+ 59
- 0
src/main/java/com/zipcodewilmington/phonebook/PhoneBook.java View File

@@ -1,7 +1,66 @@
1 1
 package com.zipcodewilmington.phonebook;
2 2
 
3
+import java.util.ArrayList;
4
+import java.util.HashMap;
5
+import java.util.TreeMap;
6
+
3 7
 /**
4 8
  * Created by leon on 1/23/18.
5 9
  */
10
+//the class
6 11
 public class PhoneBook {
12
+    //constructor
13
+    public PhoneBook(){
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();
16
+    }
17
+
18
+
19
+    public void setAdd(String name, String number){
20
+
21
+
22
+    }
23
+
24
+    public void setLookup(String name){
25
+
26
+    }
27
+
28
+    public void setRemove(String name){
29
+
30
+    }
31
+
32
+    public void setDisplay(String name, String number){
33
+
34
+    }
35
+
36
+    public void setReverseLookup(String number){
37
+
38
+    }
39
+
40
+    public String getNumber(){
41
+        return null;
42
+    }
43
+
44
+    public String getAdd(){
45
+        return null;
46
+    }
47
+
48
+    public String getLookup(){
49
+        return null;
50
+    }
51
+
52
+
53
+    public String getRemove(){
54
+        return null;
55
+    }
56
+
57
+    public String getDisplay(){
58
+        return null;
59
+    }
60
+
61
+    public String getReverseLookup(){
62
+        return null;
63
+    }
64
+
65
+
7 66
 }

+ 40
- 1
src/test/java/com/zipcodewilmington/phonebook/PhoneBookTest.java View File

@@ -1,7 +1,46 @@
1 1
 package com.zipcodewilmington.phonebook;
2 2
 
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
6
+import java.util.TreeMap;
7
+
3 8
 /**
4 9
  * Created by leon on 1/23/18.
5 10
  */
6 11
 public class PhoneBookTest {
7
-}
12
+
13
+    @Test
14
+    public void AddTest(){
15
+        //Given
16
+        String expectedname = "Marlon";
17
+        String expectednumber = "8005674563";
18
+        //When
19
+        PhoneBook phoneBook = new PhoneBook();
20
+        //Then
21
+
22
+    }
23
+
24
+    @Test
25
+    public void LookupTest(){
26
+        //Given
27
+        String expectedname = "Katrice";
28
+        String expectednumber = "8567744773";
29
+        //When
30
+        PhoneBook phonebook = new PhoneBook();
31
+        //Then
32
+        //String actualnamephonebook = phonebook.treemap.getKey();
33
+        //String actualnumberphonebook = phonebook.treemap.getKey();
34
+
35
+
36
+        String actualnumber = phonebook.getNumber();
37
+        Assert.assertEquals(expectednumber, actualnumber);
38
+    }
39
+
40
+
41
+
42
+    }
43
+
44
+
45
+
46
+

+ 134
- 0
src/test/java/com/zipcodewilmington/phonebook/TestPerson.java View File

@@ -0,0 +1,134 @@
1
+package com.zipcodewilmington.phonebook;
2
+
3
+import java.util.ArrayList;
4
+import org.junit.Assert;
5
+import org.junit.Test;
6
+
7
+public class TestPerson {
8
+
9
+
10
+
11
+
12
+
13
+    @Test
14
+    public void testGetName() {
15
+        //we place the expected on top
16
+        String expected = "Nathaniel";
17
+        Person person = new Person("Nathaniel", expected);
18
+
19
+
20
+        //I don't need a setter, because i did "this.name"...remember
21
+        String actual = person.getName();
22
+        Assert.assertEquals(expected, actual);
23
+
24
+    }
25
+
26
+    @Test
27
+    public void testGetPhoneNumbers(){
28
+        String expected = "8567744773";
29
+        Person person = new Person("Nathaniel",expected);
30
+
31
+
32
+        ArrayList<String> actual = person.getPhoneNumbers();
33
+        Assert.assertEquals(expected, actual);
34
+    }
35
+
36
+    @Test
37
+    public void testSetAddAdditionalNumbers(){
38
+        //Given
39
+        String expected = "Karen";
40
+
41
+        //When
42
+        person.setPhoneNumbers(expected);
43
+
44
+
45
+    }
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+  /*  @Test
55
+    public void testSetAddName() {
56
+        Person person = new Person();
57
+        String expected = "Nathaniel";
58
+
59
+        person.setAddName(expected);
60
+
61
+        String actual = person.getAddName();
62
+        Assert.assertEquals(expected, actual);
63
+
64
+
65
+    }
66
+
67
+
68
+    @Test
69
+    public void testSetAddNumber() {
70
+        Person person = new Person();
71
+        String expected = "8567744733";
72
+
73
+        person.setAddNumber(expected);
74
+
75
+        String actual = person.getAddNumber();
76
+        Assert.assertEquals(expected, actual);
77
+    }
78
+
79
+    @Test
80
+    public void testSetLookup() {
81
+        Person person = new Person();
82
+        String expected = "Samantha";
83
+
84
+        person.setLookup(expected);
85
+
86
+        String actual = person.getLookup();
87
+        Assert.assertEquals(expected, actual);
88
+    }
89
+
90
+    @Test
91
+    public void testSetRemoveName() {
92
+        Person person = new Person();
93
+        String expected = "Removal";
94
+
95
+        person.setRemoveName(expected);
96
+
97
+        String actual = person.getRemoveName();
98
+        Assert.assertEquals(expected, actual);
99
+    }
100
+
101
+    @Test
102
+    public void testSetRemoveNumber() {
103
+        Person person = new Person();
104
+        String expected = "Remove Number";
105
+
106
+        person.setRemoveNumber(expected);
107
+
108
+        String actual = person.getRemoveNumber();
109
+        Assert.assertEquals(expected, actual);
110
+    }
111
+
112
+    @Test
113
+    public void testSetListNames() {
114
+        Person person = new Person();
115
+        String expected = "List of Names";
116
+
117
+        person.setListNames(expected);
118
+
119
+        String actual = person.getListNames();
120
+        Assert.assertEquals(expected, actual);
121
+    }
122
+
123
+    @Test
124
+    public void testSetListNumber() {
125
+        Person person = new Person;
126
+        String expected = "List Number";
127
+
128
+        person.setListNumber(expected);
129
+
130
+        String actual = person.getListNumber();
131
+        Assert.assertEquals(expected, actual);
132
+    }*/
133
+
134
+}