Alfredo Castillo 6 yıl önce
ebeveyn
işleme
f89deb2757
8 değiştirilmiş dosya ile 389 ekleme ve 29 silme
  1. 9
    0
      .idea/ZCW-PhoneBook.iml
  2. 6
    0
      .idea/misc.xml
  3. 8
    0
      .idea/modules.xml
  4. 6
    0
      .idea/vcs.xml
  5. 246
    0
      .idea/workspace.xml
  6. 42
    1
      PhoneBook.java
  7. 51
    23
      PhoneBookTest.java
  8. 21
    5
      package.bluej

+ 9
- 0
.idea/ZCW-PhoneBook.iml Dosyayı Görüntüle

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module type="JAVA_MODULE" version="4">
3
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+    <exclude-output />
5
+    <content url="file://$MODULE_DIR$" />
6
+    <orderEntry type="inheritedJdk" />
7
+    <orderEntry type="sourceFolder" forTests="false" />
8
+  </component>
9
+</module>

+ 6
- 0
.idea/misc.xml Dosyayı Görüntüle

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="JavaScriptSettings">
4
+    <option name="languageLevel" value="ES6" />
5
+  </component>
6
+</project>

+ 8
- 0
.idea/modules.xml Dosyayı Görüntüle

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/ZCW-PhoneBook.iml" filepath="$PROJECT_DIR$/.idea/ZCW-PhoneBook.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6
- 0
.idea/vcs.xml Dosyayı Görüntüle

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="" vcs="Git" />
5
+  </component>
6
+</project>

+ 246
- 0
.idea/workspace.xml Dosyayı Görüntüle

@@ -0,0 +1,246 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="07834e83-76e7-4581-8740-0b708f6b6b5d" name="Default" comment="">
5
+      <change beforePath="$PROJECT_DIR$/PhoneBook.java" beforeDir="false" afterPath="$PROJECT_DIR$/PhoneBook.java" afterDir="false" />
6
+      <change beforePath="$PROJECT_DIR$/PhoneBookTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/PhoneBookTest.java" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/package.bluej" beforeDir="false" afterPath="$PROJECT_DIR$/package.bluej" afterDir="false" />
8
+    </list>
9
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
10
+    <option name="TRACKING_ENABLED" value="true" />
11
+    <option name="SHOW_DIALOG" value="false" />
12
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
13
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
14
+    <option name="LAST_RESOLUTION" value="IGNORE" />
15
+  </component>
16
+  <component name="FileEditorManager">
17
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
18
+      <file leaf-file-name="PhoneBook.java" pinned="false" current-in-tab="true">
19
+        <entry file="file://$PROJECT_DIR$/PhoneBook.java">
20
+          <provider selected="true" editor-type-id="text-editor" />
21
+        </entry>
22
+      </file>
23
+      <file leaf-file-name="PhoneBookTest.class" pinned="false" current-in-tab="false">
24
+        <entry file="file://$PROJECT_DIR$/PhoneBookTest.class">
25
+          <provider selected="true" editor-type-id="text-editor">
26
+            <state relative-caret-position="165">
27
+              <caret line="11" selection-start-line="11" selection-end-line="11" />
28
+            </state>
29
+          </provider>
30
+        </entry>
31
+      </file>
32
+      <file leaf-file-name="PhoneBookTest.ctxt" pinned="false" current-in-tab="false">
33
+        <entry file="file://$PROJECT_DIR$/PhoneBookTest.ctxt">
34
+          <provider selected="true" editor-type-id="text-editor" />
35
+        </entry>
36
+      </file>
37
+    </leaf>
38
+  </component>
39
+  <component name="Git.Settings">
40
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
41
+  </component>
42
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
43
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
44
+  <component name="JsGulpfileManager">
45
+    <detection-done>true</detection-done>
46
+    <sorting>DEFINITION_ORDER</sorting>
47
+  </component>
48
+  <component name="NodePackageJsonFileManager">
49
+    <packageJsonPaths />
50
+  </component>
51
+  <component name="ProjectFrameBounds">
52
+    <option name="x" value="138" />
53
+    <option name="y" value="42" />
54
+    <option name="width" value="1134" />
55
+    <option name="height" value="785" />
56
+  </component>
57
+  <component name="ProjectView">
58
+    <navigator proportions="" version="1">
59
+      <foldersAlwaysOnTop value="true" />
60
+    </navigator>
61
+    <panes>
62
+      <pane id="Scope" />
63
+      <pane id="AndroidView" />
64
+      <pane id="PackagesPane" />
65
+      <pane id="ProjectPane">
66
+        <subPane>
67
+          <expand>
68
+            <path>
69
+              <item name="ZCW-PhoneBook" type="b2602c69:ProjectViewProjectNode" />
70
+              <item name="ZCW-PhoneBook" type="462c0819:PsiDirectoryNode" />
71
+            </path>
72
+            <path>
73
+              <item name="ZCW-PhoneBook" type="b2602c69:ProjectViewProjectNode" />
74
+              <item name="ZCW-PhoneBook" type="462c0819:PsiDirectoryNode" />
75
+              <item name=".idea" type="462c0819:PsiDirectoryNode" />
76
+            </path>
77
+          </expand>
78
+          <select />
79
+        </subPane>
80
+      </pane>
81
+    </panes>
82
+  </component>
83
+  <component name="PropertiesComponent">
84
+    <property name="WebServerToolWindowFactoryState" value="false" />
85
+    <property name="aspect.path.notification.shown" value="true" />
86
+    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
87
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
88
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
89
+  </component>
90
+  <component name="RunDashboard">
91
+    <option name="ruleStates">
92
+      <list>
93
+        <RuleState>
94
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
95
+        </RuleState>
96
+        <RuleState>
97
+          <option name="name" value="StatusDashboardGroupingRule" />
98
+        </RuleState>
99
+      </list>
100
+    </option>
101
+  </component>
102
+  <component name="RunManager">
103
+    <configuration default="true" type="Application" factoryName="Application">
104
+      <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
105
+    </configuration>
106
+    <configuration default="true" type="JUnit" factoryName="JUnit">
107
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
108
+      <option name="ALTERNATIVE_JRE_PATH" />
109
+      <option name="PACKAGE_NAME" />
110
+      <option name="MAIN_CLASS_NAME" />
111
+      <option name="METHOD_NAME" />
112
+      <option name="TEST_OBJECT" value="class" />
113
+      <option name="VM_PARAMETERS" value="-ea" />
114
+      <option name="PARAMETERS" />
115
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
116
+      <option name="PASS_PARENT_ENVS" value="true" />
117
+      <option name="TEST_SEARCH_SCOPE">
118
+        <value defaultName="singleModule" />
119
+      </option>
120
+      <patterns />
121
+    </configuration>
122
+    <configuration default="true" type="TestNG" factoryName="TestNG">
123
+      <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
124
+      <option name="ALTERNATIVE_JRE_PATH" />
125
+      <option name="SUITE_NAME" />
126
+      <option name="PACKAGE_NAME" />
127
+      <option name="MAIN_CLASS_NAME" />
128
+      <option name="METHOD_NAME" />
129
+      <option name="GROUP_NAME" />
130
+      <option name="TEST_OBJECT" value="CLASS" />
131
+      <option name="VM_PARAMETERS" value="-ea" />
132
+      <option name="PARAMETERS" />
133
+      <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
134
+      <option name="OUTPUT_DIRECTORY" />
135
+      <option name="PASS_PARENT_ENVS" value="true" />
136
+      <option name="TEST_SEARCH_SCOPE">
137
+        <value defaultName="singleModule" />
138
+      </option>
139
+      <option name="USE_DEFAULT_REPORTERS" value="false" />
140
+      <option name="PROPERTIES_FILE" />
141
+      <properties />
142
+      <listeners />
143
+    </configuration>
144
+  </component>
145
+  <component name="SvnConfiguration">
146
+    <configuration />
147
+  </component>
148
+  <component name="TaskManager">
149
+    <task active="true" id="Default" summary="Default task">
150
+      <changelist id="07834e83-76e7-4581-8740-0b708f6b6b5d" name="Default" comment="" />
151
+      <created>1529178788692</created>
152
+      <option name="number" value="Default" />
153
+      <option name="presentableId" value="Default" />
154
+      <updated>1529178788692</updated>
155
+      <workItem from="1529178790888" duration="499000" />
156
+      <workItem from="1529193482842" duration="322000" />
157
+    </task>
158
+    <servers />
159
+  </component>
160
+  <component name="TimeTrackingManager">
161
+    <option name="totallyTimeSpent" value="821000" />
162
+  </component>
163
+  <component name="ToolWindowManager">
164
+    <frame x="138" y="42" width="1134" height="785" extended-state="0" />
165
+    <editor active="true" />
166
+    <layout>
167
+      <window_info anchor="right" id="Palette" order="3" />
168
+      <window_info anchor="bottom" id="TODO" order="6" />
169
+      <window_info anchor="right" id="Palette&#9;" order="3" />
170
+      <window_info id="Image Layers" order="2" />
171
+      <window_info anchor="right" id="Capture Analysis" order="3" />
172
+      <window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
173
+      <window_info anchor="right" id="Maven Projects" order="3" />
174
+      <window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
175
+      <window_info anchor="bottom" id="Version Control" order="7" />
176
+      <window_info anchor="bottom" id="Run" order="2" />
177
+      <window_info anchor="bottom" id="Terminal" order="7" />
178
+      <window_info id="Capture Tool" order="2" />
179
+      <window_info id="Designer" order="2" />
180
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24955909" />
181
+      <window_info anchor="right" id="Database" order="3" />
182
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
183
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
184
+      <window_info id="UI Designer" order="2" />
185
+      <window_info anchor="right" id="Theme Preview" order="3" />
186
+      <window_info id="Favorites" order="2" side_tool="true" />
187
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
188
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
189
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
190
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
191
+      <window_info anchor="bottom" id="Message" order="0" />
192
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
193
+      <window_info anchor="bottom" id="Find" order="1" />
194
+    </layout>
195
+  </component>
196
+  <component name="TypeScriptGeneratedFilesManager">
197
+    <option name="version" value="1" />
198
+  </component>
199
+  <component name="VcsContentAnnotationSettings">
200
+    <option name="myLimit" value="2678400000" />
201
+  </component>
202
+  <component name="editorHistoryManager">
203
+    <entry file="file://$PROJECT_DIR$/PhoneBook.java">
204
+      <provider selected="true" editor-type-id="text-editor" />
205
+    </entry>
206
+    <entry file="file://$PROJECT_DIR$/PhoneBookTest.ctxt">
207
+      <provider selected="true" editor-type-id="text-editor" />
208
+    </entry>
209
+    <entry file="file://$PROJECT_DIR$/PhoneBookTest.class">
210
+      <provider selected="true" editor-type-id="text-editor">
211
+        <state relative-caret-position="75">
212
+          <caret line="6" lean-forward="true" selection-start-line="6" selection-end-line="6" />
213
+        </state>
214
+      </provider>
215
+    </entry>
216
+    <entry file="file://$PROJECT_DIR$/PhoneBookTest.ctxt">
217
+      <provider selected="true" editor-type-id="text-editor" />
218
+    </entry>
219
+    <entry file="file://$PROJECT_DIR$/PhoneBookTest.class">
220
+      <provider selected="true" editor-type-id="text-editor">
221
+        <state relative-caret-position="165">
222
+          <caret line="11" selection-start-line="11" selection-end-line="11" />
223
+        </state>
224
+      </provider>
225
+    </entry>
226
+    <entry file="file://$PROJECT_DIR$/PhoneBook.java">
227
+      <provider selected="true" editor-type-id="text-editor" />
228
+    </entry>
229
+  </component>
230
+  <component name="masterDetails">
231
+    <states>
232
+      <state key="ProjectJDKs.UI">
233
+        <settings>
234
+          <last-edited>1.8</last-edited>
235
+          <splitter-proportions>
236
+            <option name="proportions">
237
+              <list>
238
+                <option value="0.2" />
239
+              </list>
240
+            </option>
241
+          </splitter-proportions>
242
+        </settings>
243
+      </state>
244
+    </states>
245
+  </component>
246
+</project>

+ 42
- 1
PhoneBook.java Dosyayı Görüntüle

@@ -1,7 +1,48 @@
1
- 
1
+import java.util.Map;
2
+import java.util.TreeMap;
2 3
 
3 4
 /**
4 5
  * Created by leon on 1/23/18.
5 6
  */
6 7
 public class PhoneBook {
8
+    private Map<String, String> phoneBook = new TreeMap<String, String>();
9
+
10
+    public String add(String name, String phonenumber){
11
+        phoneBook.put(name, phonenumber);
12
+        return (name + " " + phoneBook.get(name));
13
+
14
+    }
15
+
16
+    public String remove(String name){
17
+        phoneBook.remove(name);
18
+        return name;
19
+    }
20
+
21
+    public String reverseLookup(String number){
22
+        String str = "";
23
+        for(Map.Entry<String, String>entry : phoneBook.entrySet()){
24
+            if(entry.getValue().equals(number)){
25
+                str = (entry.getKey());
26
+            }
27
+        }
28
+        return str;
29
+    }
30
+
31
+    public String lookUp(String name){
32
+        return phoneBook.get(name);
33
+    }
34
+
35
+    public String display(){
36
+        String result = "";
37
+        
38
+        for(Map.Entry<String, String> entry : phoneBook.entrySet()){
39
+        result += (entry.getKey()) + " " + (entry.getValue() + "\n");
40
+        }
41
+        
42
+        return result;
43
+        
44
+
45
+    }
46
+
47
+   
7 48
 }

+ 51
- 23
PhoneBookTest.java Dosyayı Görüntüle

@@ -13,30 +13,58 @@ import org.junit.Test;
13 13
  */
14 14
 public class PhoneBookTest
15 15
 {
16
-    /**
17
-     * Default constructor for test class PhoneBookTest
18
-     */
19
-    public PhoneBookTest()
20
-    {
16
+    PhoneBook pb = new PhoneBook();
17
+    
18
+    @Test
19
+    public void PhoneBookAdd(){
20
+    String expected = "bobo 333666444";
21
+    
22
+    String actual = pb.add("bobo", "333666444");
23
+    
24
+    assertEquals(expected, actual);
21 25
     }
22
-
23
-    /**
24
-     * Sets up the test fixture.
25
-     *
26
-     * Called before every test case method.
27
-     */
28
-    @Before
29
-    public void setUp()
30
-    {
26
+    
27
+    @Test
28
+    public void PhoneBookRemove(){
29
+    String expected = "anything";
30
+    
31
+    String actual = pb.remove("anything");
32
+    
33
+    assertEquals(expected, actual);
34
+    
31 35
     }
32
-
33
-    /**
34
-     * Tears down the test fixture.
35
-     *
36
-     * Called after every test case method.
37
-     */
38
-    @After
39
-    public void tearDown()
40
-    {
36
+    
37
+    @Test
38
+    public void PhoneBookLookUp(){
39
+    //when
40
+    pb.add("fufu", "8888888");
41
+    
42
+    //expected
43
+    String expected = "8888888";
44
+    
45
+    //actual
46
+    String actual = pb.lookUp("fufu");
47
+    
48
+    assertEquals(expected, actual);
49
+    
50
+    }
51
+    
52
+    @Test
53
+    public void reverseLookUp(){
54
+    //when
55
+    pb.add("buu", "89898989");
56
+    
57
+    String expected = "buu";
58
+    
59
+    String actual = pb.reverseLookup("89898989");
60
+    
61
+    assertEquals(expected, actual);
62
+    }
63
+    
64
+    @Test
65
+    public void DisplayTest(){
66
+    //when
67
+    
41 68
     }
69
+   
42 70
 }

+ 21
- 5
package.bluej Dosyayı Görüntüle

@@ -1,4 +1,7 @@
1 1
 #BlueJ package file
2
+dependency1.from=PhoneBookTest
3
+dependency1.to=PhoneBook
4
+dependency1.type=UsesDependency
2 5
 editor.fx.0.height=0
3 6
 editor.fx.0.width=0
4 7
 editor.fx.0.x=0
@@ -9,12 +12,12 @@ package.divider.horizontal=0.6
9 12
 package.divider.vertical=0.8007380073800738
10 13
 package.editor.height=427
11 14
 package.editor.width=674
12
-package.editor.x=427
13
-package.editor.y=143
15
+package.editor.x=137
16
+package.editor.y=52
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