Browse Source

updated commit and push

Jamez-s 6 years ago
parent
commit
45113fdde3
12 changed files with 386 additions and 13 deletions
  1. 9
    0
      .idea/ZCW-PhoneBook.iml
  2. 6
    0
      .idea/compiler.xml
  3. 7
    0
      .idea/misc.xml
  4. 8
    0
      .idea/modules.xml
  5. 6
    0
      .idea/uiDesigner.xml
  6. 6
    0
      .idea/vcs.xml
  7. 272
    0
      .idea/workspace.xml
  8. 46
    11
      PhoneBook.java
  9. 24
    1
      PhoneBookTest.java
  10. 0
    0
      comparable java
  11. 1
    1
      package.bluej
  12. 1
    0
      pets

+ 9
- 0
.idea/ZCW-PhoneBook.iml View File

@@ -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/compiler.xml View File

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="CompilerConfiguration">
4
+    <bytecodeTargetLevel target="8" />
5
+  </component>
6
+</project>

+ 7
- 0
.idea/misc.xml View File

@@ -0,0 +1,7 @@
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
+  <component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
7
+</project>

+ 8
- 0
.idea/modules.xml View File

@@ -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/uiDesigner.xml View File

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

+ 6
- 0
.idea/vcs.xml View File

@@ -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>

+ 272
- 0
.idea/workspace.xml View File

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

+ 46
- 11
PhoneBook.java View File

@@ -6,16 +6,27 @@ import java.util.*;
6 6
 public class PhoneBook {
7 7
   String name;
8 8
   String phoneNumber;
9
-  TreeMap<String, String> phoneBook = new TreeMap<>();
9
+  TreeMap<String, ArrayList<String>> phoneBook = new TreeMap<>();
10 10
 
11
-  public PhoneBook(TreeMap<String, String> phoneBook) {
11
+  public PhoneBook(TreeMap<String, ArrayList<String>> phoneBook) {
12 12
     this.phoneBook = phoneBook;
13 13
   }
14 14
 
15 15
   public PhoneBook(){}
16 16
 
17 17
   public void add(String name, String phoneNumber){
18
-    phoneBook.put(name, phoneNumber);
18
+    ArrayList<String> list;
19
+
20
+    if (!phoneBook.containsKey(name)) {
21
+      list = new ArrayList<>();
22
+      phoneBook.put(name, list);
23
+    }
24
+    else
25
+    {
26
+      list = phoneBook.get(name);
27
+      list.add(phoneNumber);
28
+      phoneBook.replace(name, list);
29
+    }
19 30
   }
20 31
 
21 32
   public void remove(String name){
@@ -23,16 +34,30 @@ public class PhoneBook {
23 34
   }
24 35
 
25 36
   public String lookup(String name){
26
-    return phoneBook.get(name);
37
+    ArrayList<String> numbers = phoneBook.get(name);
38
+    StringBuilder sb = new StringBuilder();
39
+
40
+    for (int i=0; i<numbers.size(); i++) {
41
+      sb.append(numbers.get(i));
42
+      if (i == numbers.size()-1) {
43
+        break;
44
+      } else {
45
+        sb.append(", ");
46
+      }
47
+    }
48
+    sb.append("");
49
+    return sb.toString();
27 50
   }
28 51
 
29 52
   public String reverseLookup(String phoneNumber) {
30
-    for (Map.Entry<String, String> e : phoneBook.entrySet()) {
53
+    for (Map.Entry<String, ArrayList<String>> e : phoneBook.entrySet()) {
31 54
       String name = e.getKey();
32
-      String thisNumber = e.getValue();
55
+      ArrayList<String> numbers = e.getValue();
33 56
 
34
-      if (thisNumber == phoneNumber) {
35
-        return name;
57
+      for (String s : numbers) {
58
+        if (s == phoneNumber) {
59
+          return name;
60
+        }
36 61
       }
37 62
     }
38 63
     return "Name not found";
@@ -41,11 +66,21 @@ public class PhoneBook {
41 66
   public String display() {
42 67
     StringBuilder sb = new StringBuilder();
43 68
 
44
-    for (Map.Entry<String, String> e : phoneBook.entrySet()){
69
+    for (Map.Entry<String, ArrayList<String>> e : phoneBook.entrySet()){
45 70
       String name = e.getKey();
46
-      String thisNumber = e.getValue();
71
+      ArrayList<String> numbers = e.getValue();
47 72
 
48
-      sb.append(name).append(" ").append(thisNumber).append("\n");
73
+      sb.append(name).append(" ");
74
+
75
+      for (int i=0; i<numbers.size(); i++) {
76
+        sb.append(numbers.get(i));
77
+        if (i == numbers.size()-1) {
78
+          break;
79
+        } else {
80
+          sb.append(", ");
81
+        }
82
+      }
83
+      sb.append("");
49 84
     }
50 85
     return sb.toString();
51 86
   }

+ 24
- 1
PhoneBookTest.java View File

@@ -16,7 +16,7 @@ import java.util.*;
16 16
 public class PhoneBookTest
17 17
 {
18 18
 
19
-    TreeMap<String, String> phoneBook = new TreeMap<>();
19
+    TreeMap<String, ArrayList<String>> phoneBook = new TreeMap<>();
20 20
     /**
21 21
      * Default constructor for test class PhoneBookTest
22 22
      */
@@ -95,4 +95,27 @@ public class PhoneBookTest
95 95
       String actual = pb.reverseLookup("222-444-5555");
96 96
       Assert.assertEquals(expected, actual);
97 97
     }
98
+
99
+    // Testing list of phonenumbers for an entry
100
+    @Test
101
+    public void TestFive() {
102
+        String expected = "Dog 111-222-3333, 444-555-6666\n";
103
+        PhoneBook pb = new PhoneBook(phoneBook);
104
+        
105
+        pb.add("Dog", "111-222-3333");
106
+        pb.add("Dog", "444-555-6666");
107
+        
108
+        String actual = pb.display();
109
+        Assert.assertEquals(expected, actual);
110
+    }
111
+    
112
+
113
+    @Test
114
+    public void Test2()
115
+    {
116
+    }
117
+
118
+    
98 119
 }
120
+
121
+

+ 0
- 0
comparable java View File


+ 1
- 1
package.bluej View File

@@ -5,7 +5,7 @@ dependency1.type=UsesDependency
5 5
 editor.fx.0.height=722
6 6
 editor.fx.0.width=800
7 7
 editor.fx.0.x=590
8
-editor.fx.0.y=136
8
+editor.fx.0.y=125
9 9
 objectbench.height=101
10 10
 objectbench.width=461
11 11
 package.divider.horizontal=0.6

+ 1
- 0
pets View File

@@ -0,0 +1 @@
1
+private PetOwner petOwner;