Browse Source

a little further along

Katrice Williams-Dredden 6 years ago
parent
commit
32fef2f8fa

+ 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>

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

@@ -0,0 +1,21 @@
1
+package com.zipcodewilmington.phonebook;
2
+
3
+//the class
4
+public class Person {
5
+    private String name;
6
+    private String number;
7
+
8
+    public Person(String name, String number){
9
+        this.name = name;
10
+        this.number = number;
11
+
12
+    }
13
+    //creating get methods
14
+    public String getName() {
15
+        return name;
16
+    }
17
+
18
+    public String getNumber() {
19
+        return number;
20
+    }
21
+}

+ 37
- 20
src/main/java/com/zipcodewilmington/phonebook/PhoneBook.java View File

@@ -1,43 +1,60 @@
1 1
 package com.zipcodewilmington.phonebook;
2 2
 
3
+import java.util.ArrayList;
4
+import java.util.HashMap;
5
+
3 6
 /**
4 7
  * Created by leon on 1/23/18.
5 8
  */
9
+//the class
6 10
 public class PhoneBook {
7 11
 
8
-    private String name;
9
-    private String number;
12
+    private String addName;
13
+    private String addNumber;
14
+    //has to be a person object to go into the array list
15
+    ArrayList<Person> contactList = new ArrayList();
10 16
 
11
-    //the instance of the phone book (ask about this, not 1000% clear
12
-    public Person(String name, String phoneNumber) {
13
-        this.name = name;
14
-        this.phoneNumber = phoneNumber;
15
-    }
17
+    public void setAddName(String name){
18
+        this.addName = addName;
16 19
 
20
+    }
17 21
 
18
-    //add number
19
-    public void addEntry() {
22
+    public void setAddNumber(String number){
23
+        this.addNumber = addNumber;
24
+    }
20 25
 
21
-        return null;
26
+    public void setLookup(String name){
27
+        this.lookup = lookup;
22 28
     }
23 29
 
24
-    //remove number and name
25
-    public void removeContact(String name) {
30
+    public void setRemove(String name, String number){
31
+        this.name = name;
32
+        this.number = number;
33
+    }
26 34
 
35
+    public void setListNames(String name){
36
+        this.name = name;
27 37
     }
28 38
 
29
-    //Look up entry
30
-    public void listAllNumbers() {
31
-        String[] listAllNumbers = new String[];
32
-        return;
39
+    public void setListNumber(String number){
40
+        this.number = number;
33 41
     }
34 42
 
35
-    //making a list of all entries
36
-    public String getphoneNumbers() {
37
-        return getphoneNumbers();
43
+
44
+
45
+
46
+
47
+
48
+
49
+    /*public void setAddName(String addName, String addNumber){
50
+        contact.put(addName, addNumber);
38 51
     }
39 52
 
40
-}
53
+    public void setAddNumber(){
54
+
55
+    }*/
56
+
57
+
41 58
 
42 59
 
43 60
 

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

@@ -1,28 +1,96 @@
1 1
 package com.zipcodewilmington.phonebook;
2
+
2 3
 import org.junit.Test;
3 4
 /**
4 5
  * Created by leon on 1/23/18.
5 6
  */
6 7
 public class PhoneBookTest {
7
-//test for adding an entry
8
+
9
+    @Test
10
+    public void testSetAddName() {
11
+        PhoneBook testing = new PhoneBook();
12
+        String expected = "Nathaniel";
13
+
14
+        testing.setAddName(expected);
15
+
16
+        String actual = testing.getAddName();
17
+        Assert.assertEquals(expected, actual);
18
+
19
+
20
+    }
21
+
22
+
8 23
     @Test
9
-    public void test addEntry1() {
10
-        String expected = "856-774-4773";
11
-        PhoneBook.addEntry("Rodney", "856-774-4773");
12
-        String actual = PhoneBook.listAllNumbers("Rodney");
24
+    public void testSetAddNumber() {
25
+        PhoneBook testing = new PhoneBook();
26
+        String expected = "8567744733";
13 27
 
14
-        TestUtils.assertEquality(expected, actual);
28
+        testing.setAddNumber(expected);
29
+
30
+        String actual = testing.getAddNumber();
31
+        Assert.assertEquals(expected, actual);
32
+    }
33
+
34
+    @Test
35
+    public void testSetLookup() {
36
+        PhoneBook testing = new PhoneBook();
37
+        String expected = "Samantha";
38
+
39
+        testing.setLookup(expected);
40
+
41
+        String actual = testing.getLookup();
42
+        Assert.assertEquals(expected, actual);
15 43
     }
16 44
 
17 45
     @Test
18
-    public void test addEntry2() {
19
-        String expected = "856-774-4773";
20
-        PhoneBook.addEntry("Rodney", "856-774-4773");
21
-        String actual = PhoneBook.listAllNumbers("Rodney");
46
+    public void testSetRemoveName() {
47
+        Phonebook testing = new PhoneBook();
48
+        String expected = "Removal";
49
+
50
+        testing.setRemoveName(expected);
22 51
 
23
-        TestUtils.assertEquality(expected, actual);
52
+        String actual = testing.getRemoveName();
53
+        Assert.assertEquals(expected, actual);
24 54
     }
25
-//
55
+
56
+    @Test
57
+    public void testSetRemoveNumber() {
58
+        PhoneBook testing = new PhoneBook();
59
+        String expected = "Remove Number";
60
+
61
+        testing.setRemoveNumber(expected);
62
+
63
+        String actual = testing.getRemoveNumber();
64
+        Assert.assertEquals(expected, actual);
65
+    }
66
+
67
+    @Test
68
+    public void testSetListNames() {
69
+        PhoneBook testing = new PhoneBook();
70
+        String expected = "List of Names";
71
+
72
+        testing.setListNames(expected);
73
+
74
+        String actual = testing.getListNames();
75
+        Assert.assertEquals(expected, actual);
76
+    }
77
+
78
+    @Test
79
+    public void testSetListNumber() {
80
+        PhoneBook person = new PhoneBook();
81
+        String expected = "List Number";
82
+
83
+        person.setListNumber(expected);
84
+
85
+        String actual = person.getListNumber();
86
+        Assert.assertEquals(expected, actual);
87
+    }
88
+
89
+
90
+
91
+
92
+    }
93
+
94
+
26 95
 
27 96
 
28
-}

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

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