parent
commit
66053c2f99
4 ha cambiato i file con 155 aggiunte e 58 eliminazioni
  1. 77
    32
      .idea/workspace.xml
  2. 22
    16
      PhoneBook.java
  3. 54
    8
      PhoneBookTest.java
  4. 2
    2
      package.bluej

+ 77
- 32
.idea/workspace.xml Vedi File

@@ -2,7 +2,6 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="03385383-e9d0-4df8-963f-75a98f3a335b" name="Default" comment="">
5
-      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
6 5
       <change beforePath="$PROJECT_DIR$/PhoneBook.java" beforeDir="false" afterPath="$PROJECT_DIR$/PhoneBook.java" afterDir="false" />
7 6
       <change beforePath="$PROJECT_DIR$/PhoneBookTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/PhoneBookTest.java" afterDir="false" />
8 7
       <change beforePath="$PROJECT_DIR$/package.bluej" beforeDir="false" afterPath="$PROJECT_DIR$/package.bluej" afterDir="false" />
@@ -19,11 +18,8 @@
19 18
       <file leaf-file-name="PhoneBook.class" pinned="false" current-in-tab="false">
20 19
         <entry file="file://$PROJECT_DIR$/PhoneBook.class">
21 20
           <provider selected="true" editor-type-id="text-editor">
22
-            <state relative-caret-position="112">
23
-              <caret line="8" selection-start-line="8" selection-end-line="8" />
24
-              <folding>
25
-                <element signature="e#0#373#0" expanded="true" />
26
-              </folding>
21
+            <state relative-caret-position="66">
22
+              <caret line="16" selection-start-line="16" selection-end-line="16" />
27 23
             </state>
28 24
           </provider>
29 25
         </entry>
@@ -31,17 +27,32 @@
31 27
       <file leaf-file-name="PhoneBook.java" pinned="false" current-in-tab="false">
32 28
         <entry file="file://$PROJECT_DIR$/PhoneBook.java">
33 29
           <provider selected="true" editor-type-id="text-editor">
34
-            <state relative-caret-position="266">
35
-              <caret line="19" selection-start-line="19" selection-end-line="19" />
30
+            <state relative-caret-position="287">
31
+              <caret line="22" column="23" selection-start-line="22" selection-start-column="23" selection-end-line="22" selection-end-column="23" />
32
+            </state>
33
+          </provider>
34
+        </entry>
35
+      </file>
36
+      <file leaf-file-name="README.md" pinned="false" current-in-tab="true">
37
+        <entry file="file://$PROJECT_DIR$/README.md">
38
+          <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
39
+            <state split_layout="SECOND">
40
+              <first_editor />
41
+              <second_editor />
36 42
             </state>
37 43
           </provider>
38 44
         </entry>
39 45
       </file>
40
-      <file leaf-file-name="PhoneBookTest.java" pinned="false" current-in-tab="true">
46
+      <file leaf-file-name="PhoneBookTest.java" pinned="false" current-in-tab="false">
41 47
         <entry file="file://$PROJECT_DIR$/PhoneBookTest.java">
42 48
           <provider selected="true" editor-type-id="text-editor">
43
-            <state relative-caret-position="406">
44
-              <caret line="32" column="38" lean-forward="true" selection-start-line="32" selection-start-column="38" selection-end-line="32" selection-end-column="38" />
49
+            <state relative-caret-position="-15">
50
+              <caret line="27" column="14" selection-start-line="27" selection-start-column="14" selection-end-line="27" selection-end-column="14" />
51
+              <folding>
52
+                <element signature="imports" expanded="true" />
53
+                <element signature="e#495#496#0" expanded="true" />
54
+                <element signature="e#548#549#0" expanded="true" />
55
+              </folding>
45 56
             </state>
46 57
           </provider>
47 58
         </entry>
@@ -68,10 +79,9 @@
68 79
   <component name="NodePackageJsonFileManager">
69 80
     <packageJsonPaths />
70 81
   </component>
71
-  <component name="ProjectFrameBounds" extendedState="6">
72
-    <option name="y" value="303" />
82
+  <component name="ProjectFrameBounds" fullScreen="true">
73 83
     <option name="width" value="1280" />
74
-    <option name="height" value="732" />
84
+    <option name="height" value="800" />
75 85
   </component>
76 86
   <component name="ProjectView">
77 87
     <navigator proportions="" version="1">
@@ -90,8 +100,9 @@
90 100
         </subPane>
91 101
       </pane>
92 102
       <pane id="Scope" />
93
-      <pane id="PackagesPane" />
94 103
       <pane id="AndroidView" />
104
+      <pane id="PackagesPane" />
105
+      <pane id="Course" />
95 106
     </panes>
96 107
   </component>
97 108
   <component name="PropertiesComponent">
@@ -169,11 +180,12 @@
169 180
       <updated>1528488969279</updated>
170 181
       <workItem from="1528488971234" duration="105000" />
171 182
       <workItem from="1528900440059" duration="2665000" />
183
+      <workItem from="1529424942448" duration="2575000" />
172 184
     </task>
173 185
     <servers />
174 186
   </component>
175 187
   <component name="TimeTrackingManager">
176
-    <option name="totallyTimeSpent" value="2770000" />
188
+    <option name="totallyTimeSpent" value="5345000" />
177 189
   </component>
178 190
   <component name="TodoView">
179 191
     <todo-panel id="selected-file">
@@ -185,7 +197,7 @@
185 197
     </todo-panel>
186 198
   </component>
187 199
   <component name="ToolWindowManager">
188
-    <frame x="0" y="23" width="1280" height="732" extended-state="6" />
200
+    <frame x="0" y="0" width="1280" height="800" extended-state="6" />
189 201
     <editor active="true" />
190 202
     <layout>
191 203
       <window_info anchor="right" id="Palette" order="3" />
@@ -198,12 +210,11 @@
198 210
       <window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
199 211
       <window_info anchor="bottom" id="Run" order="2" />
200 212
       <window_info anchor="bottom" id="Version Control" order="7" weight="0.32913387" />
201
-      <window_info active="true" anchor="bottom" id="Terminal" order="7" visible="true" weight="0.37480316" />
213
+      <window_info anchor="bottom" id="Terminal" order="7" weight="0.3737931" />
202 214
       <window_info id="Capture Tool" order="2" />
203 215
       <window_info id="Designer" order="2" />
204
-      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2536349" />
216
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26979" />
205 217
       <window_info anchor="right" id="Database" order="3" />
206
-      <window_info anchor="bottom" id="Find" order="1" />
207 218
       <window_info id="Learn" order="2" />
208 219
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
209 220
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
@@ -216,6 +227,7 @@
216 227
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
217 228
       <window_info anchor="bottom" id="Message" order="0" />
218 229
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
230
+      <window_info anchor="bottom" id="Find" order="1" />
219 231
     </layout>
220 232
   </component>
221 233
   <component name="TypeScriptGeneratedFilesManager">
@@ -227,23 +239,33 @@
227 239
   <component name="editorHistoryManager">
228 240
     <entry file="file://$PROJECT_DIR$/PhoneBook.class">
229 241
       <provider selected="true" editor-type-id="text-editor">
230
-        <state>
231
-          <folding>
232
-            <element signature="e#0#373#0" expanded="true" />
233
-          </folding>
242
+        <state relative-caret-position="115">
243
+          <caret line="8" selection-start-line="8" selection-end-line="8" />
234 244
         </state>
235 245
       </provider>
236 246
     </entry>
237
-    <entry file="file://$PROJECT_DIR$/PhoneBook.class">
247
+    <entry file="file://$PROJECT_DIR$/PhoneBook.java">
238 248
       <provider selected="true" editor-type-id="text-editor">
239
-        <state relative-caret-position="112">
240
-          <caret line="8" selection-start-line="8" selection-end-line="8" />
249
+        <state relative-caret-position="437">
250
+          <caret line="19" selection-start-line="19" selection-end-line="19" />
251
+        </state>
252
+      </provider>
253
+    </entry>
254
+    <entry file="file://$PROJECT_DIR$/PhoneBookTest.java">
255
+      <provider selected="true" editor-type-id="text-editor">
256
+        <state relative-caret-position="667">
257
+          <caret line="32" column="38" lean-forward="true" selection-start-line="32" selection-start-column="38" selection-end-line="32" selection-end-column="38" />
241 258
           <folding>
242
-            <element signature="e#0#373#0" expanded="true" />
259
+            <element signature="imports" expanded="true" />
260
+            <element signature="e#495#496#0" expanded="true" />
261
+            <element signature="e#548#549#0" expanded="true" />
243 262
           </folding>
244 263
         </state>
245 264
       </provider>
246 265
     </entry>
266
+    <entry file="file://$PROJECT_DIR$/PhoneBook.class">
267
+      <provider selected="true" editor-type-id="text-editor" />
268
+    </entry>
247 269
     <entry file="file://$PROJECT_DIR$/Untitled-1.md">
248 270
       <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
249 271
         <state split_layout="SPLIT">
@@ -252,17 +274,40 @@
252 274
         </state>
253 275
       </provider>
254 276
     </entry>
277
+    <entry file="file://$PROJECT_DIR$/README.TXT">
278
+      <provider selected="true" editor-type-id="text-editor" />
279
+    </entry>
255 280
     <entry file="file://$PROJECT_DIR$/PhoneBook.java">
256 281
       <provider selected="true" editor-type-id="text-editor">
257
-        <state relative-caret-position="266">
258
-          <caret line="19" selection-start-line="19" selection-end-line="19" />
282
+        <state relative-caret-position="287">
283
+          <caret line="22" column="23" selection-start-line="22" selection-start-column="23" selection-end-line="22" selection-end-column="23" />
259 284
         </state>
260 285
       </provider>
261 286
     </entry>
262 287
     <entry file="file://$PROJECT_DIR$/PhoneBookTest.java">
263 288
       <provider selected="true" editor-type-id="text-editor">
264
-        <state relative-caret-position="406">
265
-          <caret line="32" column="38" lean-forward="true" selection-start-line="32" selection-start-column="38" selection-end-line="32" selection-end-column="38" />
289
+        <state relative-caret-position="-15">
290
+          <caret line="27" column="14" selection-start-line="27" selection-start-column="14" selection-end-line="27" selection-end-column="14" />
291
+          <folding>
292
+            <element signature="imports" expanded="true" />
293
+            <element signature="e#495#496#0" expanded="true" />
294
+            <element signature="e#548#549#0" expanded="true" />
295
+          </folding>
296
+        </state>
297
+      </provider>
298
+    </entry>
299
+    <entry file="file://$PROJECT_DIR$/PhoneBook.class">
300
+      <provider selected="true" editor-type-id="text-editor">
301
+        <state relative-caret-position="66">
302
+          <caret line="16" selection-start-line="16" selection-end-line="16" />
303
+        </state>
304
+      </provider>
305
+    </entry>
306
+    <entry file="file://$PROJECT_DIR$/README.md">
307
+      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
308
+        <state split_layout="SECOND">
309
+          <first_editor />
310
+          <second_editor />
266 311
         </state>
267 312
       </provider>
268 313
     </entry>

+ 22
- 16
PhoneBook.java Vedi File

@@ -5,33 +5,39 @@ import java.util.*;
5 5
 public class PhoneBook {
6 6
     private String phoneNumber;
7 7
     private String name;
8
+    private Map<String,String> input;
8 9
 
9
-    private Map<String,String> input = new TreeMap<String,String>();
10
-
11
-    public static void main(String [] args){
12
-
13
-    }
10
+ 
14 11
 
15 12
     public PhoneBook(){
16
-        this.input = new TreeMap<String, String>();
13
+        input = new TreeMap<String,String>();
17 14
     }
18 15
 
19 16
     public void display(){
20
-        if(this.input.containsKey(name)){
21
-            for(Map.Entry<String,String> input: input.entrySet()){
22
-
23
-                String value = input.getValue();
24
-                String key = input.getKey();
17
+        
18
+        for(Object keyValue:input.keySet()){
19
+            System.out.println("Key: " + keyValue + ". Value: " + input.get(keyValue));
25 20
             }
26
-
27
-        }
28 21
     }
29 22
 
30
-    public void remove(String name){
31
-        this.input.remove(name);
23
+    public String remove(String name){
24
+        return input.remove(name);
32 25
     }
33 26
 
34 27
     public void AddInput(String name,String phoneNumber){
35
-        this.input.put(name,phoneNumber);
28
+        input.put(name,phoneNumber);
29
+    }
30
+
31
+    public String lookup(String name){
32
+        String value = input.get(name);
33
+        return value;
34
+    }
35
+
36
+    public String reverseLookup(String name,String phoneNumber){
37
+        String value = "";
38
+        if(input.containsValue(phoneNumber)){
39
+            value = phoneNumber;
40
+        }
41
+        return value;
36 42
     }
37 43
 }

+ 54
- 8
PhoneBookTest.java Vedi File

@@ -1,10 +1,8 @@
1
-
2
-
3 1
 import static org.junit.Assert.*;
4 2
 import org.junit.After;
5 3
 import org.junit.Before;
6 4
 import org.junit.Test;
7
-
5
+import java.util.*;
8 6
 /**
9 7
  * The test class PhoneBookTest.
10 8
  *
@@ -13,6 +11,8 @@ import org.junit.Test;
13 11
  */
14 12
 public class PhoneBookTest
15 13
 {
14
+    PhoneBook phoneBook = new PhoneBook();
15
+    public Map<String,String> input = new TreeMap<String,String>();
16 16
     /**
17 17
      * Default constructor for test class PhoneBookTest
18 18
      */
@@ -21,15 +21,61 @@ public class PhoneBookTest
21 21
     {
22 22
         PhoneBook phoneBook = new PhoneBook();
23 23
     }
24
+
24 25
     @Test
25 26
     public void testAddingPhoneNumber(){
26
-        PhoneBook phoneBook = new PhoneBook();
27
-        String name = "Khalil";
28
-        String phoneNumber = "215-555-555";
29
-        String expected = name + phoneNumber;
30 27
         
31
-        phoneBook.AddInput(name,phoneNumber);
28
+        input.put("Amy","232-323-3233");
32 29
         
30
+        int expectedSize = 1;
31
+        
32
+        int actual1 = input.size();
33
+
34
+        //When
35
+         assertEquals(expectedSize,actual1);
33 36
     }
34 37
 
38
+    @Test
39
+    public void testRemovingPhoneNumber(){
40
+        //Given
41
+       
42
+        input.put("Amy","232-323-3233");
43
+        //Then
44
+        String expected = null;
45
+        String actual = phoneBook.remove("Amy");
46
+
47
+        //When
48
+        assertEquals(expected,actual);
49
+    }
50
+    
51
+    @Test
52
+    public void testLookUp(){
53
+    
54
+        input.put("Amy","232-323-3233");
55
+        input.put("John","243-567-9963");
56
+        input.put("Brian","555-555-5555");
57
+        
58
+        
59
+        String expected = "Amy"+"232-323-3233";
60
+        boolean key = false;
61
+        if(input.containsKey("Amy")){
62
+                key = true; 
63
+            }
64
+            assertTrue(key);
65
+    }
66
+     @Test
67
+    public void testReverseLookUp(){
68
+    
69
+        input.put("Amy","232-323-3233");
70
+        input.put("John","243-567-9963");
71
+        input.put("Brian","555-555-5555");
72
+        
73
+        
74
+        String expected = "Amy"+"232-323-3233";
75
+        boolean value = false;
76
+        if(input.containsValue("232-323-3233")){
77
+                value = true; 
78
+            }
79
+            assertTrue(value);
80
+    }
35 81
 }

+ 2
- 2
package.bluej Vedi File

@@ -4,8 +4,8 @@ dependency1.to=PhoneBook
4 4
 dependency1.type=UsesDependency
5 5
 editor.fx.0.height=722
6 6
 editor.fx.0.width=800
7
-editor.fx.0.x=29
8
-editor.fx.0.y=23
7
+editor.fx.0.x=240
8
+editor.fx.0.y=27
9 9
 objectbench.height=101
10 10
 objectbench.width=461
11 11
 package.divider.horizontal=0.6