Browse Source

removed unnecessary comments

Carolynn Vansant 6 years ago
parent
commit
6e6340796a

+ 7
- 14
src/main/java/com/zipcodewilmington/phonebook/PhoneBook.java View File

@@ -6,28 +6,23 @@ import java.util.*;
6 6
  */
7 7
 public class PhoneBook {
8 8
 
9
-    //instance variable
10 9
     private TreeMap<String, ArrayList<String>> treeMap;
11 10
 
12
-
13
-    // void "no arguments" constructor -creates empty map
14 11
     public PhoneBook() {
15 12
         this.treeMap= new TreeMap<String, ArrayList<String>>();
16 13
     }
17 14
 
18
-    // single argument constructor -type Map -creates new map w/ same key/value mappings as argument
19 15
     public PhoneBook(TreeMap treeMap) {
20 16
         this.treeMap = treeMap;
21 17
     }
22 18
 
23
-    //add a name & number entry, add number
24 19
     public void addEntry(String name, ArrayList<String> number) {
25 20
         if (!treeMap.containsKey(name)) {
26 21
             treeMap.put(name, number);
27 22
         }
28 23
     }
29 24
 
30
-    //add numbers to existing entries
25
+
31 26
     public void addNumberToEntry(String name, String number) {
32 27
         for (Map.Entry<String, ArrayList<String>> entry : treeMap.entrySet()) {
33 28
             if (name.equals(entry.getKey())) {
@@ -37,7 +32,7 @@ public class PhoneBook {
37 32
         }
38 33
     }
39 34
 
40
-    //remove numbers from existing entries
35
+
41 36
     public void removeNumberFromEntry(String name, String number) {
42 37
         for (Map.Entry<String, ArrayList<String>> entry : treeMap.entrySet()) {
43 38
             if (entry.getKey().equals(name)) {
@@ -48,31 +43,29 @@ public class PhoneBook {
48 43
         }
49 44
     }
50 45
 
51
-    //remove entire entry
46
+
52 47
     public void removeEntry(String name) {
53 48
             treeMap.remove(name);
54 49
     }
55 50
 
56
-    //lookup: find phone number from name
51
+
57 52
     public ArrayList<String> lookup(String name) {
58 53
         return treeMap.get(name);
59 54
     }
60 55
 
61
-    //reverse lookup: find name from number
56
+
62 57
     public String reverseLookup (String number) {
63 58
         String name = "";
64 59
         for(Map.Entry<String, ArrayList<String>> entry: treeMap.entrySet()) {
65 60
             ArrayList<String> value = entry.getValue();
66 61
             for(String revnumber: value) {
67
-                if(number.contains(revnumber)) {
68
-                    name = entry.getKey();
69
-                }
62
+                if(number.contains(revnumber)) name = entry.getKey();
70 63
             }
71 64
         }
72 65
         return name;
73 66
     }
74 67
 
75
-    //print out all of the entries in PhoneBook
68
+
76 69
     public String display(){
77 70
         StringBuilder printOut = new StringBuilder();
78 71
         for(Map.Entry<String, ArrayList<String>> entry: treeMap.entrySet()) {

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

@@ -2,16 +2,14 @@ package com.zipcodewilmington.phonebook;
2 2
 
3 3
 import org.junit.Assert;
4 4
 import org.junit.Test;
5
-import sun.nio.cs.ext.SJIS;
6
-
7 5
 import java.util.ArrayList;
8 6
 import java.util.Arrays;
9
-import java.util.TreeMap;
10 7
 
11 8
 /**
12 9
  * Created by leon on 1/23/18.
13 10
  */
14 11
 public class PhoneBookTest {
12
+
15 13
     @Test
16 14
     public void testDefaultConstructor() {
17 15
         PhoneBook book = new PhoneBook();
@@ -70,7 +68,6 @@ public class PhoneBookTest {
70 68
 
71 69
     @Test
72 70
     public void testRemoveEntry() {
73
-
74 71
         //Given
75 72
         PhoneBook book = new PhoneBook();
76 73
         ArrayList<String> bobNumber = new ArrayList<String>(Arrays.asList("302-555-2222","302-555-3456"));
@@ -86,7 +83,6 @@ public class PhoneBookTest {
86 83
 
87 84
     @Test
88 85
     public void testLookup(){
89
-        //To test if lookup returns all of the person's phone numbers
90 86
         //Given
91 87
         PhoneBook book = new PhoneBook();
92 88
         ArrayList<String> expectedNumber = new ArrayList<String>(Arrays.asList("302-555-2223","302-555-3456"));
@@ -99,7 +95,6 @@ public class PhoneBookTest {
99 95
 
100 96
     @Test
101 97
     public void testLookup2(){
102
-        //To test if lookup picks out the right person when there are multiple entries
103 98
         //Given
104 99
         PhoneBook book = new PhoneBook();
105 100
         ArrayList<String> bobNumber = new ArrayList<String>(Arrays.asList("302-555-2223"));
@@ -115,7 +110,6 @@ public class PhoneBookTest {
115 110
 
116 111
     @Test
117 112
     public void testreverseLookup(){
118
-        // to test if right person is returned when searching by one of multiple phone numbers
119 113
         //Given
120 114
         PhoneBook book = new PhoneBook();
121 115
         ArrayList<String> bobNumber = new ArrayList<String>(Arrays.asList("302-555-2223","302-555-5555"));