Browse Source

need to do some more research

Ryan Small 6 years ago
parent
commit
ccd104e936
3 changed files with 61 additions and 10 deletions
  1. 23
    1
      PhoneBook.java
  2. 15
    2
      PhoneBookTest.java
  3. 23
    7
      package.bluej

+ 23
- 1
PhoneBook.java View File

@@ -1,7 +1,29 @@
1
- 
1
+import java.util.Scanner;
2
+import java.util.ArrayList;
2 3
 
3 4
 /**
4 5
  * Created by leon on 1/23/18.
5 6
  */
6 7
 public class PhoneBook {
8
+    private String name;
9
+    private String phoneNumber;
10
+    
11
+    public PhoneBook()
12
+    {
13
+        
14
+    }
15
+    
16
+    public String add(String n, String number)
17
+    {
18
+        n = name;
19
+        number = phoneNumber;
20
+        
21
+        return null;
22
+    }
23
+    
24
+    public String lookUp(String n)
25
+    {
26
+        n = name;
27
+        return null;
28
+    }
7 29
 }

+ 15
- 2
PhoneBookTest.java View File

@@ -1,5 +1,3 @@
1
-
2
-
3 1
 import static org.junit.Assert.*;
4 2
 import org.junit.After;
5 3
 import org.junit.Before;
@@ -19,6 +17,7 @@ public class PhoneBookTest
19 17
     public PhoneBookTest()
20 18
     {
21 19
     }
20
+    private PhoneBook phoneBook;
22 21
 
23 22
     /**
24 23
      * Sets up the test fixture.
@@ -28,6 +27,20 @@ public class PhoneBookTest
28 27
     @Before
29 28
     public void setUp()
30 29
     {
30
+        phoneBook = new PhoneBook();
31
+    }
32
+
33
+    @Test
34
+    public void testAdd()
35
+    {
36
+        //plug in a String name here using methods from main class
37
+        String name = "Ryan"; 
38
+        String expectedPhoneNumber= "123-456-7890"; 
39
+        phoneBook.add(name, expectedPhoneNumber);
40
+        String actualPhoneNumber = phoneBook.lookUp(name);
41
+        
42
+        assertEquals(actualPhoneNumber, expectedPhoneNumber);
43
+        
31 44
     }
32 45
 
33 46
     /**

+ 23
- 7
package.bluej View File

@@ -1,8 +1,11 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=0
3
-editor.fx.0.width=0
4
-editor.fx.0.x=0
5
-editor.fx.0.y=0
2
+dependency1.from=PhoneBookTest
3
+dependency1.to=PhoneBook
4
+dependency1.type=UsesDependency
5
+editor.fx.0.height=722
6
+editor.fx.0.width=800
7
+editor.fx.0.x=240
8
+editor.fx.0.y=26
6 9
 objectbench.height=101
7 10
 objectbench.width=461
8 11
 package.divider.horizontal=0.6
@@ -13,8 +16,8 @@ package.editor.x=427
13 16
 package.editor.y=143
14 17
 package.frame.height=600
15 18
 package.frame.width=800
16
-package.numDependencies=0
17
-package.numTargets=1
19
+package.numDependencies=1
20
+package.numTargets=2
18 21
 package.showExtends=true
19 22
 package.showUses=true
20 23
 project.charset=UTF-8
@@ -23,4 +26,17 @@ readme.name=@README
23 26
 readme.width=47
24 27
 readme.x=10
25 28
 readme.y=10
26
-
29
+target1.height=50
30
+target1.name=PhoneBookTest
31
+target1.showInterface=false
32
+target1.type=UnitTestTargetJunit4
33
+target1.width=120
34
+target1.x=100
35
+target1.y=10
36
+target2.height=50
37
+target2.name=PhoneBook
38
+target2.showInterface=false
39
+target2.type=ClassTarget
40
+target2.width=100
41
+target2.x=70
42
+target2.y=70