Browse Source

Next commit

Arin Turpin 6 years ago
parent
commit
0879e68e10
2 changed files with 24 additions and 7 deletions
  1. 9
    4
      PhoneBook.java
  2. 15
    3
      PhoneBookTest.java

+ 9
- 4
PhoneBook.java View File

@@ -11,12 +11,13 @@ public class PhoneBook{
11 11
     List<String> multipleNumbers = new LinkedList<>();
12 12
  //   public static boolean electronicPhonebook = true;
13 13
  //   Scanner input = new Scanner(System.in);
14
- //   Collection<String> c;
15
- //   Iterator<String> iter = c.iterator();
14
+ // HashMap<List, String> c;
15
+ // Iterator<String> iter = c.iterator();
16 16
     public PhoneBook(){
17 17
     }
18
-    public void add(List multipleNumbers, String name){
19
-        phonebook.put(multipleNumbers, name);
18
+    
19
+    public void add(List <String> number, String name){
20
+        phonebook.put(number, name);
20 21
     }
21 22
     
22 23
     public void remove(String name){
@@ -31,6 +32,10 @@ public class PhoneBook{
31 32
         return phonebook.get(number);
32 33
     }
33 34
     
35
+  //  public void removeRecord(){
36
+  //      iter.forEachRemaining(Map<List, String>, iter.remove(List));
37
+  //  }
38
+    
34 39
     public void display(){
35 40
         System.out.println("                         ***** WLECOME TO THE WORLD BOOK *****           ");
36 41
         for (Map.Entry<List,String> entry : phonebook.entrySet()){

+ 15
- 3
PhoneBookTest.java View File

@@ -6,6 +6,8 @@ import org.junit.Before;
6 6
 import org.junit.Test;
7 7
 public class PhoneBookTest{
8 8
     Map<String, String> testPhonebook = new TreeMap<>();
9
+    Collection<String> c;
10
+    Iterator<String> iter = c.iterator();
9 11
     public PhoneBookTest(){
10 12
     }
11 13
     
@@ -42,12 +44,22 @@ public class PhoneBookTest{
42 44
     @Test
43 45
     public void reverseLookupTest(){
44 46
         testPhonebook.put("9393939", "Hirself");
45
-        testPhonebook.get("9393939");
46 47
         
47
-        String actual = testPhonebook.get("Hirself");
48
-        String expected = "9393939";
48
+        String actual = testPhonebook.get("9393939");
49
+        String expected = "Hirself";
49 50
         assertEquals(actual, expected);
50 51
     }
51 52
     
53
+    @Test
54
+    public void removeRecordTest(){
55
+        testPhonebook.put("9393939", "Hirself");
56
+        testPhonebook.put("8484848", "Moped");
57
+        
58
+        for(TreeMap<String, String> entry : c){
59
+            entry.remove();
60
+        }
61
+        String actual = null;
62
+    }
63
+    
52 64
 
53 65
 }