Connor Dunnigan il y a 6 ans
Parent
révision
634590ac0e

+ 217
- 56
arraz/.idea/workspace.xml Voir le fichier

@@ -2,13 +2,9 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="b3ba50be-3b8d-441a-8e91-35865d2e3cb7" name="Default Changelist" comment="">
5
-      <change afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/.idea/libraries/Maven__junit_junit_4_0.xml" afterDir="false" />
7
-      <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
8
-      <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
9
-      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
10
-      <change beforePath="$PROJECT_DIR$/arraz.iml" beforeDir="false" afterPath="$PROJECT_DIR$/arraz.iml" afterDir="false" />
11
-      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
5
+      <change afterPath="$PROJECT_DIR$/src/main/java/MaxMin.java" afterDir="false" />
6
+      <change afterPath="$PROJECT_DIR$/src/main/java/OddEven.java" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
12 8
       <change beforePath="$PROJECT_DIR$/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Arraz.java" afterDir="false" />
13 9
       <change beforePath="$PROJECT_DIR$/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/ArrazTest.java" afterDir="false" />
14 10
     </list>
@@ -20,14 +16,26 @@
20 16
     <option name="LAST_RESOLUTION" value="IGNORE" />
21 17
   </component>
22 18
   <component name="FileEditorManager">
23
-    <splitter split-orientation="horizontal" split-proportion="0.5">
19
+    <splitter split-orientation="horizontal" split-proportion="0.5105198">
24 20
       <split-first>
25
-        <leaf>
21
+        <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
26 22
           <file pinned="false" current-in-tab="true">
27 23
             <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
28 24
               <provider selected="true" editor-type-id="text-editor">
29
-                <state relative-caret-position="414">
30
-                  <caret line="18" lean-forward="true" selection-start-line="18" selection-end-line="18" />
25
+                <state relative-caret-position="557">
26
+                  <caret line="206" column="50" selection-start-line="206" selection-start-column="50" selection-end-line="206" selection-end-column="50" />
27
+                  <folding>
28
+                    <element signature="imports" expanded="true" />
29
+                    <element signature="e#5210#5211#0" expanded="true" />
30
+                    <element signature="e#5274#5275#0" expanded="true" />
31
+                    <element signature="e#5791#5792#0" expanded="true" />
32
+                    <element signature="e#5843#5844#0" expanded="true" />
33
+                    <element signature="e#5917#5918#0" expanded="true" />
34
+                    <element signature="e#6036#6037#0" expanded="true" />
35
+                    <element signature="e#6157#6158#0" expanded="true" />
36
+                    <element signature="e#6222#6223#0" expanded="true" />
37
+                    <element signature="e#6287#6288#0" expanded="true" />
38
+                  </folding>
31 39
                 </state>
32 40
               </provider>
33 41
             </entry>
@@ -35,39 +43,75 @@
35 43
         </leaf>
36 44
       </split-first>
37 45
       <split-second>
38
-        <leaf>
46
+        <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
39 47
           <file pinned="false" current-in-tab="true">
40 48
             <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
41 49
               <provider selected="true" editor-type-id="text-editor">
42
-                <state relative-caret-position="161">
43
-                  <caret line="7" column="29" lean-forward="true" selection-start-line="7" selection-start-column="29" selection-end-line="7" selection-end-column="29" />
50
+                <state relative-caret-position="3634">
51
+                  <caret line="158" column="27" selection-start-line="158" selection-start-column="27" selection-end-line="158" selection-end-column="27" />
44 52
                   <folding>
45 53
                     <element signature="imports" expanded="true" />
54
+                    <element signature="e#3882#3883#0" expanded="true" />
55
+                    <element signature="e#3950#3951#0" expanded="true" />
46 56
                   </folding>
47 57
                 </state>
48 58
               </provider>
49 59
             </entry>
50 60
           </file>
61
+          <file pinned="false" current-in-tab="false">
62
+            <entry file="file://$PROJECT_DIR$/src/main/java/MaxMin.java">
63
+              <provider selected="true" editor-type-id="text-editor">
64
+                <state relative-caret-position="230">
65
+                  <caret line="10" column="49" selection-start-line="10" selection-start-column="49" selection-end-line="10" selection-end-column="49" />
66
+                </state>
67
+              </provider>
68
+            </entry>
69
+          </file>
70
+          <file pinned="false" current-in-tab="false">
71
+            <entry file="file://$PROJECT_DIR$/src/main/java/OddEven.java">
72
+              <provider selected="true" editor-type-id="text-editor" />
73
+            </entry>
74
+          </file>
51 75
         </leaf>
52 76
       </split-second>
53 77
     </splitter>
54 78
   </component>
79
+  <component name="FileTemplateManagerImpl">
80
+    <option name="RECENT_TEMPLATES">
81
+      <list>
82
+        <option value="Class" />
83
+      </list>
84
+    </option>
85
+  </component>
86
+  <component name="FindInProjectRecents">
87
+    <findStrings>
88
+      <find>remove</find>
89
+      <find>remov</find>
90
+      <find>new Integ</find>
91
+      <find>int</find>
92
+    </findStrings>
93
+    <replaceStrings>
94
+      <replace>Integer</replace>
95
+    </replaceStrings>
96
+  </component>
55 97
   <component name="Git.Settings">
56 98
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
57 99
   </component>
58 100
   <component name="IdeDocumentHistory">
59 101
     <option name="CHANGED_PATHS">
60 102
       <list>
103
+        <option value="$PROJECT_DIR$/src/main/java/OddEven.java" />
104
+        <option value="$PROJECT_DIR$/src/main/java/MaxMin.java" />
61 105
         <option value="$PROJECT_DIR$/src/main/java/Arraz.java" />
62 106
         <option value="$PROJECT_DIR$/src/test/java/ArrazTest.java" />
63 107
       </list>
64 108
     </option>
65 109
   </component>
66
-  <component name="ProjectFrameBounds">
67
-    <option name="x" value="16" />
68
-    <option name="y" value="23" />
69
-    <option name="width" value="1228" />
70
-    <option name="height" value="748" />
110
+  <component name="ProjectFrameBounds" fullScreen="true">
111
+    <option name="x" value="-345" />
112
+    <option name="y" value="-1080" />
113
+    <option name="width" value="1920" />
114
+    <option name="height" value="1080" />
71 115
   </component>
72 116
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
73 117
   <component name="ProjectView">
@@ -76,7 +120,6 @@
76 120
     </navigator>
77 121
     <panes>
78 122
       <pane id="Scope" />
79
-      <pane id="PackagesPane" />
80 123
       <pane id="ProjectPane">
81 124
         <subPane>
82 125
           <expand>
@@ -119,16 +162,17 @@
119 162
           <select />
120 163
         </subPane>
121 164
       </pane>
165
+      <pane id="PackagesPane" />
122 166
     </panes>
123 167
   </component>
124 168
   <component name="PropertiesComponent">
125 169
     <property name="WebServerToolWindowFactoryState" value="false" />
126 170
     <property name="aspect.path.notification.shown" value="true" />
127
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544155039323" />
171
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544297521528" />
128 172
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
129 173
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
130 174
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
131
-    <property name="settings.editor.selected.configurable" value="MTConfigurable" />
175
+    <property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
132 176
   </component>
133 177
   <component name="RunDashboard">
134 178
     <option name="ruleStates">
@@ -142,12 +186,50 @@
142 186
       </list>
143 187
     </option>
144 188
   </component>
145
-  <component name="RunManager">
146
-    <configuration name="ArrazTest.testSumValsOfArr" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
189
+  <component name="RunManager" selected="JUnit.ArrazTest">
190
+    <configuration name="ArrazTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
191
+      <module name="arraz" />
192
+      <option name="PACKAGE_NAME" value="" />
193
+      <option name="MAIN_CLASS_NAME" value="ArrazTest" />
194
+      <method v="2">
195
+        <option name="Make" enabled="true" />
196
+      </method>
197
+    </configuration>
198
+    <configuration name="ArrazTest.testInsertAtEnd" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
199
+      <module name="arraz" />
200
+      <option name="PACKAGE_NAME" value="" />
201
+      <option name="MAIN_CLASS_NAME" value="ArrazTest" />
202
+      <option name="METHOD_NAME" value="testInsertAtEnd" />
203
+      <option name="TEST_OBJECT" value="method" />
204
+      <method v="2">
205
+        <option name="Make" enabled="true" />
206
+      </method>
207
+    </configuration>
208
+    <configuration name="ArrazTest.testInsertAtIndex" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
209
+      <module name="arraz" />
210
+      <option name="PACKAGE_NAME" value="" />
211
+      <option name="MAIN_CLASS_NAME" value="ArrazTest" />
212
+      <option name="METHOD_NAME" value="testInsertAtIndex" />
213
+      <option name="TEST_OBJECT" value="method" />
214
+      <method v="2">
215
+        <option name="Make" enabled="true" />
216
+      </method>
217
+    </configuration>
218
+    <configuration name="ArrazTest.testInsertAtStart" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
219
+      <module name="arraz" />
220
+      <option name="PACKAGE_NAME" value="" />
221
+      <option name="MAIN_CLASS_NAME" value="ArrazTest" />
222
+      <option name="METHOD_NAME" value="testInsertAtStart" />
223
+      <option name="TEST_OBJECT" value="method" />
224
+      <method v="2">
225
+        <option name="Make" enabled="true" />
226
+      </method>
227
+    </configuration>
228
+    <configuration name="ArrazTest.testMaxMin" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
147 229
       <module name="arraz" />
148 230
       <option name="PACKAGE_NAME" value="" />
149 231
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
150
-      <option name="METHOD_NAME" value="testSumValsOfArr" />
232
+      <option name="METHOD_NAME" value="testMaxMin" />
151 233
       <option name="TEST_OBJECT" value="method" />
152 234
       <method v="2">
153 235
         <option name="Make" enabled="true" />
@@ -155,12 +237,16 @@
155 237
     </configuration>
156 238
     <recent_temporary>
157 239
       <list>
158
-        <item itemvalue="JUnit.ArrazTest.testSumValsOfArr" />
240
+        <item itemvalue="JUnit.ArrazTest" />
241
+        <item itemvalue="JUnit.ArrazTest.testInsertAtStart" />
242
+        <item itemvalue="JUnit.ArrazTest.testInsertAtEnd" />
243
+        <item itemvalue="JUnit.ArrazTest.testInsertAtIndex" />
244
+        <item itemvalue="JUnit.ArrazTest.testMaxMin" />
159 245
       </list>
160 246
     </recent_temporary>
161 247
   </component>
162 248
   <component name="SvnConfiguration">
163
-    <configuration />
249
+    <configuration>$USER_HOME$/.subversion</configuration>
164 250
   </component>
165 251
   <component name="TaskManager">
166 252
     <task active="true" id="Default" summary="Default task">
@@ -169,51 +255,81 @@
169 255
       <option name="number" value="Default" />
170 256
       <option name="presentableId" value="Default" />
171 257
       <updated>1544151809976</updated>
172
-      <workItem from="1544151813460" duration="2687000" />
258
+      <workItem from="1544151813460" duration="21120000" />
259
+      <workItem from="1544218395041" duration="11180000" />
260
+      <workItem from="1544240763762" duration="101000" />
261
+      <workItem from="1544240892972" duration="7355000" />
173 262
     </task>
174 263
     <servers />
175 264
   </component>
176 265
   <component name="TestHistory">
177
-    <history-entry file="ArrazTest_testSumValsOfArr - 2018.12.06 at 22h 51m 00s.xml">
178
-      <configuration name="ArrazTest.testSumValsOfArr" configurationId="JUnit" />
266
+    <history-entry file="ArrazTest_testInsertAtIndex - 2018.12.08 at 14h 00m 26s.xml">
267
+      <configuration name="ArrazTest.testInsertAtIndex" configurationId="JUnit" />
268
+    </history-entry>
269
+    <history-entry file="ArrazTest_testInsertAtIndex - 2018.12.08 at 14h 00m 49s.xml">
270
+      <configuration name="ArrazTest.testInsertAtIndex" configurationId="JUnit" />
271
+    </history-entry>
272
+    <history-entry file="ArrazTest_testMaxMin - 2018.12.08 at 14h 09m 54s.xml">
273
+      <configuration name="ArrazTest.testMaxMin" configurationId="JUnit" />
274
+    </history-entry>
275
+    <history-entry file="ArrazTest_testMaxMin - 2018.12.08 at 14h 11m 15s.xml">
276
+      <configuration name="ArrazTest.testMaxMin" configurationId="JUnit" />
277
+    </history-entry>
278
+    <history-entry file="ArrazTest_testMaxMin - 2018.12.08 at 14h 13m 40s.xml">
279
+      <configuration name="ArrazTest.testMaxMin" configurationId="JUnit" />
280
+    </history-entry>
281
+    <history-entry file="ArrazTest_testInsertAtIndex - 2018.12.08 at 14h 14m 42s.xml">
282
+      <configuration name="ArrazTest.testInsertAtIndex" configurationId="JUnit" />
283
+    </history-entry>
284
+    <history-entry file="ArrazTest - 2018.12.08 at 14h 24m 33s.xml">
285
+      <configuration name="ArrazTest" configurationId="JUnit" />
286
+    </history-entry>
287
+    <history-entry file="ArrazTest_testInsertAtStart - 2018.12.08 at 14h 25m 26s.xml">
288
+      <configuration name="ArrazTest.testInsertAtStart" configurationId="JUnit" />
289
+    </history-entry>
290
+    <history-entry file="ArrazTest_testInsertAtEnd - 2018.12.08 at 14h 27m 25s.xml">
291
+      <configuration name="ArrazTest.testInsertAtEnd" configurationId="JUnit" />
292
+    </history-entry>
293
+    <history-entry file="ArrazTest_testInsertAtStart - 2018.12.08 at 14h 27m 35s.xml">
294
+      <configuration name="ArrazTest.testInsertAtStart" configurationId="JUnit" />
179 295
     </history-entry>
180 296
   </component>
181 297
   <component name="TimeTrackingManager">
182
-    <option name="totallyTimeSpent" value="2687000" />
298
+    <option name="totallyTimeSpent" value="39756000" />
183 299
   </component>
184 300
   <component name="ToolWindowManager">
185
-    <frame x="16" y="23" width="1228" height="748" extended-state="0" />
301
+    <frame x="-345" y="-1080" width="1920" height="1080" extended-state="0" />
186 302
     <editor active="true" />
187 303
     <layout>
188
-      <window_info id="Image Layers" />
189
-      <window_info id="Designer" />
190
-      <window_info id="UI Designer" />
191
-      <window_info id="Capture Tool" />
192
-      <window_info id="Favorites" side_tool="true" />
193
-      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.13996628" />
304
+      <window_info content_ui="combo" id="Project" order="0" weight="0.07028754" />
194 305
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
195
-      <window_info anchor="bottom" id="Messages" />
196
-      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
197
-      <window_info anchor="bottom" id="Database Changes" />
198
-      <window_info anchor="bottom" id="Version Control" />
199
-      <window_info anchor="bottom" id="Terminal" />
200
-      <window_info anchor="bottom" id="Event Log" side_tool="true" />
306
+      <window_info id="Image Layers" order="2" />
307
+      <window_info id="Designer" order="3" />
308
+      <window_info id="UI Designer" order="4" />
309
+      <window_info id="Capture Tool" order="5" />
310
+      <window_info id="Favorites" order="6" side_tool="true" />
201 311
       <window_info anchor="bottom" id="Message" order="0" />
202 312
       <window_info anchor="bottom" id="Find" order="1" />
203
-      <window_info anchor="bottom" id="Run" order="2" weight="0.3296875" />
204
-      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
313
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.37424546" />
314
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.30784708" />
205 315
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
206 316
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
207 317
       <window_info anchor="bottom" id="TODO" order="6" />
208
-      <window_info anchor="right" id="Palette" />
209
-      <window_info anchor="right" id="Theme Preview" />
210
-      <window_info anchor="right" id="Maven" />
211
-      <window_info anchor="right" id="Capture Analysis" />
212
-      <window_info anchor="right" id="Palette&#9;" />
213
-      <window_info anchor="right" id="Database" />
318
+      <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
319
+      <window_info anchor="bottom" id="Version Control" order="8" />
320
+      <window_info anchor="bottom" id="Database Changes" order="9" />
321
+      <window_info anchor="bottom" id="Terminal" order="10" weight="0.3296875" />
322
+      <window_info anchor="bottom" id="Event Log" order="11" side_tool="true" />
323
+      <window_info anchor="bottom" id="Messages" order="12" weight="0.3138833" />
214 324
       <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
215 325
       <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
216 326
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
327
+      <window_info anchor="right" id="Palette" order="3" />
328
+      <window_info anchor="right" id="Database" order="4" />
329
+      <window_info anchor="right" id="Theme Preview" order="5" />
330
+      <window_info anchor="right" id="Maven" order="6" />
331
+      <window_info anchor="right" id="Capture Analysis" order="7" />
332
+      <window_info anchor="right" id="Palette&#9;" order="8" />
217 333
     </layout>
218 334
   </component>
219 335
   <component name="TypeScriptGeneratedFilesManager">
@@ -223,19 +339,64 @@
223 339
     <entry file="file://$PROJECT_DIR$/pom.xml">
224 340
       <provider selected="true" editor-type-id="text-editor" />
225 341
     </entry>
342
+    <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/src.zip!/java/util/ArrayList.java">
343
+      <provider selected="true" editor-type-id="text-editor">
344
+        <state relative-caret-position="224">
345
+          <caret line="486" column="12" selection-start-line="486" selection-start-column="7" selection-end-line="486" selection-end-column="12" />
346
+        </state>
347
+      </provider>
348
+    </entry>
349
+    <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/src.zip!/java/util/List.java">
350
+      <provider selected="true" editor-type-id="text-editor">
351
+        <state relative-caret-position="169">
352
+          <caret line="210" column="12" selection-start-line="210" selection-start-column="12" selection-end-line="210" selection-end-column="12" />
353
+        </state>
354
+      </provider>
355
+    </entry>
356
+    <entry file="jar://$MAVEN_REPOSITORY$/junit/junit/4.0/junit-4.0.jar!/org/junit/internal/runners/TestMethodRunner.class">
357
+      <provider selected="true" editor-type-id="text-editor">
358
+        <state relative-caret-position="352">
359
+          <caret line="94" selection-start-line="94" selection-end-line="94" />
360
+        </state>
361
+      </provider>
362
+    </entry>
363
+    <entry file="file://$PROJECT_DIR$/src/main/java/MaxMin.java">
364
+      <provider selected="true" editor-type-id="text-editor">
365
+        <state relative-caret-position="230">
366
+          <caret line="10" column="49" selection-start-line="10" selection-start-column="49" selection-end-line="10" selection-end-column="49" />
367
+        </state>
368
+      </provider>
369
+    </entry>
370
+    <entry file="file://$PROJECT_DIR$/src/main/java/OddEven.java">
371
+      <provider selected="true" editor-type-id="text-editor" />
372
+    </entry>
226 373
     <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
227 374
       <provider selected="true" editor-type-id="text-editor">
228
-        <state relative-caret-position="414">
229
-          <caret line="18" lean-forward="true" selection-start-line="18" selection-end-line="18" />
375
+        <state relative-caret-position="557">
376
+          <caret line="206" column="50" selection-start-line="206" selection-start-column="50" selection-end-line="206" selection-end-column="50" />
377
+          <folding>
378
+            <element signature="imports" expanded="true" />
379
+            <element signature="e#5210#5211#0" expanded="true" />
380
+            <element signature="e#5274#5275#0" expanded="true" />
381
+            <element signature="e#5791#5792#0" expanded="true" />
382
+            <element signature="e#5843#5844#0" expanded="true" />
383
+            <element signature="e#5917#5918#0" expanded="true" />
384
+            <element signature="e#6036#6037#0" expanded="true" />
385
+            <element signature="e#6157#6158#0" expanded="true" />
386
+            <element signature="e#6222#6223#0" expanded="true" />
387
+            <element signature="e#6287#6288#0" expanded="true" />
388
+          </folding>
230 389
         </state>
231 390
       </provider>
232 391
     </entry>
233 392
     <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
234 393
       <provider selected="true" editor-type-id="text-editor">
235
-        <state relative-caret-position="161">
236
-          <caret line="7" column="29" lean-forward="true" selection-start-line="7" selection-start-column="29" selection-end-line="7" selection-end-column="29" />
394
+        <state relative-caret-position="3634">
395
+          <caret line="158" column="27" selection-start-line="158" selection-start-column="27" selection-end-line="158" selection-end-column="27" />
237 396
           <folding>
238 397
             <element signature="imports" expanded="true" />
398
+            <element signature="e#3882#3883#0" expanded="true" />
399
+            <element signature="e#3950#3951#0" expanded="true" />
239 400
           </folding>
240 401
         </state>
241 402
       </provider>

+ 203
- 3
arraz/src/main/java/Arraz.java Voir le fichier

@@ -1,18 +1,218 @@
1
+import java.util.*;
1 2
 
2 3
 public class Arraz {
3 4
 
4
-    public Arraz() {
5
-    }
5
+    public Arraz() {}
6
+
6 7
     public Integer sumValuesOfArray(Integer[] nums){
7 8
         int sum = 0;
8 9
         for(Integer i : nums)
9 10
             sum += i;
10 11
         return sum;
11 12
     }
12
-    public Double sumValuesOfArray(Double[] nums){
13
+    public Double sumDoublesOfArray(Double[] nums){
13 14
         double sum = 0;
14 15
         for(Double i : nums)
15 16
             sum += i;
16 17
         return sum;
17 18
     }
19
+    public Integer averageOfArray(Integer[] nums) {
20
+        return sumValuesOfArray(nums)/nums.length;
21
+    }
22
+
23
+    public Double doubleAverageOfArray(Double[] numsDbl){
24
+        return sumDoublesOfArray(numsDbl)/numsDbl.length;
25
+    }
26
+
27
+    public boolean contains(Integer[] nums, int i){
28
+        for (Integer val : nums)
29
+            if (val == i)
30
+                return true;
31
+        return false;
32
+    }
33
+
34
+    public Integer[] reverseArray(Integer[] nums){
35
+        Integer[] rev = new Integer[nums.length];
36
+        for(int i = nums.length-1, j = 0; i >= 0; i--,j++)
37
+            rev[j] = nums[i];
38
+        return rev;
39
+    }
40
+
41
+    public String toString(Integer[] nums){
42
+        String str = "ArrayVals: ";
43
+        for(Integer i : nums)
44
+            str += i + " ";
45
+        return str;
46
+    }
47
+
48
+    public String toString(ArrayList<Integer>nums){
49
+        String str = "ArrayVals: ";
50
+        for(Integer i : nums)
51
+            str += i + " ";
52
+        return str;
53
+    }
54
+
55
+    public OddEven getOddEvensOfArray(Integer[] nums){
56
+        int odds = 0, evens = 0;
57
+         for(Integer i : nums) {
58
+            odds += (i % 2 == 0) ? 1 : 0;
59
+            evens += (i % 2 == 0) ? 0 : 1;
60
+        }
61
+        return new OddEven(odds,evens);
62
+    }
63
+
64
+    public int findIndexOf(Object[] objArr, Object val){
65
+        for(int i = 0; i < objArr.length; i++)
66
+            if(objArr[i] == val)
67
+                return i;
68
+        return -1;
69
+    }
70
+
71
+    public Integer[] copyArrayByIterator(Integer[] nums){
72
+        Iterator<Integer> itr = Arrays.asList(nums).iterator();
73
+        Integer[] copy = new Integer[nums.length];
74
+        int i = 0;
75
+        while(itr.hasNext())
76
+            copy[i++] = itr.next();
77
+        return copy;
78
+    }
79
+
80
+    public Integer[] copyArrayByLoop(Integer[] nums){
81
+        Integer[] copy = new Integer[nums.length];
82
+        for(int i = 0;i < nums.length; i++)
83
+            copy[i] = nums[i];
84
+        return copy;
85
+    }
86
+
87
+    public Integer[] removeElementFromArray(Integer[] nums, int val){
88
+         if(contains(nums,val)) {
89
+             Integer[] newArr = new Integer[nums.length - 1];
90
+             int index = 0;
91
+             for (Integer i : nums)
92
+                 if (val != i)
93
+                     newArr[index++] = i;
94
+             return newArr;
95
+         } else
96
+             return nums;
97
+    }
98
+
99
+    public Integer[] insertIntoArrayAt(Integer[] nums,Integer index, Integer val) throws IndexOutOfBoundsException{
100
+      try {
101
+          Integer[] newArr = new Integer[nums.length + 1];
102
+          for(int i = 0; i < newArr.length; i++){
103
+              if(i < index)
104
+                  newArr[i] = nums[i];
105
+              else if(index == i)
106
+                  newArr[i] = val;
107
+              else
108
+                  newArr[i] = nums[i-1];
109
+          }
110
+          return newArr;
111
+      } catch (IndexOutOfBoundsException e) {
112
+          e.printStackTrace();
113
+      }
114
+      return nums;
115
+    }
116
+
117
+    public MaxMin findMaxMinOfArray(Integer[] nums){
118
+        Integer min = getExtrema(nums)[0];
119
+        Integer max = getExtrema(nums)[1];
120
+        return new MaxMin(min,max);
121
+    }
122
+    public static Integer[] getExtrema(Integer[] nums) {
123
+        int max = nums[0], min = nums[0];
124
+        for (int i = 1; i < nums.length; i++) {
125
+            if (nums[i] > max)
126
+                max = nums[i];
127
+            else if (nums[i] < min)
128
+                min = nums[i];
129
+        }
130
+        return new Integer[] {min,max};
131
+    }
132
+
133
+    public Integer[] removeDupesFromArray(Integer[] nums) {
134
+        SortedSet<Integer> set = new TreeSet<>(Arrays.asList(nums));
135
+        List<Integer> list = new ArrayList<>(set);
136
+        return list.toArray(new Integer[0]);
137
+    }
138
+
139
+    public Integer find2ndLargestValueFromArray(Integer[] nums){
140
+        SortedSet<Integer> set = new TreeSet<>(Arrays.asList(nums));
141
+        List<Integer> list = new ArrayList<>(set);
142
+        return list.get(list.size()-2);
143
+    }
144
+
145
+    public ArrayList<Integer> makeMeAnArrayListFromArray(Integer[] nums){
146
+        ArrayList<Integer> list = new ArrayList<>(Arrays.asList(nums));
147
+        return list;
148
+    }
149
+
150
+    public Integer[] makeMeAnArrayFromArrayList(ArrayList<Integer> list){
151
+        return list.toArray(new Integer[0]);
152
+    }
153
+
154
+    public boolean check2ArraysForEqual(Integer[] arr1, Integer[] arr2) {
155
+        for (int i = 0; i < arr1.length; i++)
156
+            if(arr1[i] != arr2[i])
157
+                return false;
158
+        return true;
159
+    }
160
+
161
+    public double averageArrayWithoutMaxMin(Integer[] nums){
162
+        Integer max = findMaxMinOfArray(nums).max;
163
+        Integer[] result = removeElementFromArray(nums, max);
164
+        Integer min = findMaxMinOfArray(result).min;
165
+        Integer[] ouput = removeElementFromArray(result, min);
166
+        return sumValuesOfArray(ouput)/(double)ouput.length;
167
+    }
168
+
169
+    public boolean arrayHas65and77(Integer[] nums){
170
+        return (contains(nums, 65) && contains(nums,77));
171
+    }
172
+
173
+    public boolean totalOfTensIs30(Integer[] nums){
174
+        int sum = 0;
175
+        for(int i: nums)
176
+            if(i == 10)
177
+                sum++;
178
+        return (sum == 3);
179
+    }
180
+
181
+    public Integer find2ndSmallestValueFromArray(Integer[] nums){
182
+        Integer mini = findMaxMinOfArray(nums).min;
183
+        Integer[] noMin = removeElementFromArray(nums, mini);
184
+        return findMaxMinOfArray(noMin).min;
185
+    }
186
+
187
+    public Integer[] reverseCopyOfArray(Integer[] nums){
188
+        return reverseArray(nums);
189
+    }
190
+
191
+    public Integer[] removeLastItem(Integer[] nums){
192
+        return removeElementFromArray(nums, nums[nums.length - 1]);
193
+    }
194
+
195
+    public Integer[] removeFirstItem(Integer[] nums){
196
+        return removeElementFromArray(nums, nums[0]);
197
+    }
198
+
199
+    public Integer[] insertAtStart(Integer[] nums, Integer val){
200
+        return insertIntoArrayAt(nums, 0, val);
201
+    }
202
+
203
+    public Integer[] insertAtEnd(Integer[] nums, Integer val){
204
+        return insertIntoArrayAt(nums,nums.length, val);
205
+    }
206
+
207
+    public Integer[] sortArrayIntoEvensThenOdds(Integer[] nums){
208
+        Integer[] result = new Integer[nums.length];
209
+        Integer front = 0;
210
+        Integer back = nums.length - 1;
211
+        for (int i : nums)
212
+            if(i % 2 == 0)
213
+                result[front++] = i;
214
+            else
215
+                result[back--] = i;
216
+        return result;
217
+    }
18 218
 }

+ 13
- 0
arraz/src/main/java/MaxMin.java Voir le fichier

@@ -0,0 +1,13 @@
1
+public class MaxMin {
2
+    public int max, min;
3
+    public MaxMin(int min, int max){
4
+        this.min = min;
5
+        this.max = max;
6
+    }
7
+
8
+    @Override
9
+    public boolean equals(Object o){
10
+        MaxMin maxMin = (MaxMin) o;
11
+        return (maxMin.min == min && maxMin.max == max);
12
+    }
13
+}

+ 13
- 0
arraz/src/main/java/OddEven.java Voir le fichier

@@ -0,0 +1,13 @@
1
+public class OddEven {
2
+    public int odds, evens;
3
+    public OddEven(int odds, int evens){
4
+        this.odds = odds;
5
+        this.evens = evens;
6
+    }
7
+
8
+    @Override
9
+    public boolean equals(Object o){
10
+        OddEven oddEven = (OddEven) o;
11
+        return (oddEven.evens == evens || oddEven.odds == odds);
12
+    }
13
+}

+ 223
- 3
arraz/src/test/java/ArrazTest.java Voir le fichier

@@ -1,14 +1,234 @@
1 1
 import junit.framework.Assert;
2 2
 import org.junit.Test;
3
+import java.util.ArrayList;
3 4
 
4 5
 public class ArrazTest {
5 6
     Arraz arraz = new Arraz();
6
-
7
+    Integer[] nums = {3,4,5,6};
8
+    Double[] numsDbl = {3D,4D,5D,6D};
7 9
     @Test
8
-    public void testSumValsOfArr(){
9
-        Integer[] nums = {3,4,5,6};
10
+   public void testSumValsOfArrInt(){
10 11
         Integer actual = arraz.sumValuesOfArray(nums);
11 12
         Assert.assertEquals(18,(int)actual);
12 13
     }
14
+    @Test
15
+    public void testSumValsOfArrDub(){
16
+        Double actual = arraz.sumDoublesOfArray(numsDbl);
17
+        Assert.assertEquals(18,actual,0);
18
+    }
19
+
20
+    @Test
21
+    public void testAvgArray(){
22
+        Integer actual = arraz.averageOfArray(nums);
23
+        Assert.assertEquals(4,(int)actual);
24
+    }
25
+
26
+    @Test
27
+    public void testAvgArrayDbl(){
28
+        Double actual = arraz.doubleAverageOfArray(numsDbl);
29
+        Assert.assertEquals(4.5, actual,0);
30
+    }
31
+
32
+    @Test
33
+    public void testContains(){
34
+        boolean actual = arraz.contains(nums, 3);
35
+        Assert.assertEquals(true, actual);
36
+    }
37
+
38
+    @Test
39
+    public void testReverseArr(){
40
+        Integer[] exp = {6,5,4,3};
41
+        Integer[] act = arraz.reverseArray(nums);
42
+        Assert.assertEquals(arraz.toString(act),arraz.toString(exp));
43
+    }
44
+
45
+    @Test
46
+    public void testOddEven(){
47
+        OddEven exp = new OddEven(2,2);
48
+        OddEven act = arraz.getOddEvensOfArray(nums);
49
+        Assert.assertEquals(exp,act);
50
+    }
51
+
52
+    @Test
53
+    public void testFindIndex(){
54
+        int actual = arraz.findIndexOf(nums,4);
55
+        Assert.assertEquals(1,actual);
56
+    }
57
+
58
+    @Test
59
+    public void testCpyByItr(){
60
+        Integer[] actArr = arraz.copyArrayByIterator(nums);
61
+        String exp = arraz.toString(nums);
62
+        String act = arraz.toString(actArr);
63
+        Assert.assertEquals(exp,act);
64
+    }
65
+
66
+    @Test
67
+    public void testCpyByLoop(){
68
+        Integer[] actArr = arraz.copyArrayByLoop(nums);
69
+        String exp = arraz.toString(nums);
70
+        String act = arraz.toString(actArr);
71
+        Assert.assertEquals(exp,act);
72
+    }
73
+
74
+    @Test
75
+    public void testRemoveArrayElement(){
76
+        Integer[] actArr = arraz.removeElementFromArray(nums,4);
77
+        String exp = "ArrayVals: 3 5 6 ";
78
+        String act = arraz.toString(actArr);
79
+        Assert.assertEquals(exp,act);
80
+    }
81
+
82
+    @Test
83
+    public void testInsertAtIndex(){
84
+        String exp = "ArrayVals: 1 3 4 5 6 ";
85
+        Integer[] actArr = arraz.insertIntoArrayAt(nums, 0,  1);
86
+        String act = arraz.toString(actArr);
87
+        Assert.assertEquals(exp, act);
88
+    }
89
+
90
+    @Test
91
+    public void testMaxMin(){
92
+        MaxMin extrema = new MaxMin(3,6);
93
+        MaxMin actExtrema = arraz.findMaxMinOfArray(nums);
94
+        Assert.assertEquals(extrema,actExtrema);
95
+    }
96
+    @Test
97
+    public void testRemoveDups(){
98
+        Integer[] testArr = {3,4,5,6,6,7,8,8,8,9};
99
+        String exp = arraz.toString(new Integer[] {3,4,5,6,7,8,9});
100
+        Integer[] actArr = arraz.removeDupesFromArray(testArr);
101
+        String act = arraz.toString(actArr);
102
+        Assert.assertEquals(exp,act);
103
+    }
104
+
105
+    @Test
106
+    public void test2ndLargest(){
107
+        Integer[] nums2 = {5,2,5,6,8,2,1};
108
+        Integer expected = 6;
109
+        Integer actual = arraz.find2ndLargestValueFromArray(nums2);
110
+        Assert.assertEquals(expected,actual);
111
+    }
112
+
113
+    @Test
114
+    public void testArrListFromArr(){
115
+        String exp = "ArrayVals: 3 4 5 6 ";
116
+        ArrayList<Integer> list = arraz.makeMeAnArrayListFromArray(nums);
117
+        Assert.assertEquals(exp,arraz.toString(list));
118
+    }
119
+
120
+    @Test
121
+    public void testArrayFromArrList(){
122
+        // : Given
123
+        ArrayList<Integer> list = new ArrayList<>();
124
+        // : When
125
+        list.add(1);
126
+        list.add(2);
127
+        String exp = "ArrayVals: 1 2 ";
128
+        Integer[] act = arraz.makeMeAnArrayFromArrayList(list);
129
+        // : Then
130
+        Assert.assertEquals(exp, arraz.toString(act));
131
+    }
132
+
133
+    @Test
134
+    public void test1check2ArraysEqual() {
135
+        Assert.assertTrue(arraz.check2ArraysForEqual(nums, nums));
136
+    }
137
+
138
+    @Test
139
+    public void test2check2ArraysEqual() {
140
+        Integer[] arr = {1,2,3,4};
141
+        Assert.assertFalse(arraz.check2ArraysForEqual(arr, nums));
142
+    }
143
+
144
+    @Test
145
+    public void test1averageWOMaxMin() {
146
+        Integer[] arr = {2,5,1,4};
147
+        double actual = arraz.averageArrayWithoutMaxMin(arr);
148
+        Assert.assertEquals(3.0, actual,0);
149
+    }
150
+
151
+    @Test
152
+    public void test2arrayHas65and77() {
153
+        Integer[] arr = {65,77,1};
154
+        Assert.assertTrue(arraz.arrayHas65and77(arr));
155
+    }
156
+
157
+    @Test
158
+    public void testTensTotal30False() {
159
+        Integer[] arr = {1,10};
160
+        Assert.assertFalse(arraz.totalOfTensIs30(arr));
161
+    }
162
+
163
+    @Test
164
+    public void testTensTotal30True() {
165
+        Integer[] arr = {1,10,2,10,3,10};
166
+        Assert.assertTrue(arraz.totalOfTensIs30(arr));
167
+    }
168
+
169
+    @Test
170
+    public void testFind2ndSmallest() {
171
+        Integer[] arr = {1,2,3,4};
172
+        Integer expected = 2;
173
+        Integer actual = arraz.find2ndSmallestValueFromArray(arr);
174
+        Assert.assertEquals(expected, actual);
175
+    }
176
+
177
+    @Test
178
+    public void testReverseCopy() {
179
+        Integer[] arr = {1,2,3};
180
+        String exp = arraz.toString(new Integer[] {3,2,1});
181
+        Integer[] actArr = arraz.reverseCopyOfArray(arr);
182
+        String act = arraz.toString(actArr);
183
+        Assert.assertEquals(exp, act);
184
+    }
185
+
186
+    @Test
187
+    public void testRemoveLastItem() {
188
+        Integer[] arr = {3,2,1,0};
189
+        String exp = arraz.toString(new Integer[] {3,2,1});
190
+        Integer[] actArr = arraz.removeLastItem(arr);
191
+        String act = arraz.toString(actArr);
192
+        Assert.assertEquals(exp, act);
193
+    }
194
+
195
+    @Test
196
+    public void testRemoveFirstItem() {
197
+        Integer[] arr = {3,2,1,0};
198
+        String exp = arraz.toString(new Integer[] {2,1,0});
199
+        Integer[] actArr = arraz.removeFirstItem(arr);
200
+        String act = arraz.toString(actArr);
201
+        Assert.assertEquals(exp, act);
202
+    }
203
+
204
+    @Test
205
+    public void testInsertAtStart() {
206
+        Integer[] arr = {3,2,1,0};
207
+        Integer numb = 100;
208
+        String exp = arraz.toString(new Integer[] {100,3,2,1,0});
209
+        Integer[] actArr = arraz.insertAtStart(arr, numb);
210
+        String act = arraz.toString(actArr);
211
+        Assert.assertEquals(exp,act);
212
+    }
213
+
214
+    @Test
215
+    public void testInsertAtEnd() {
216
+        Integer[] arr = {3,2,1,0};
217
+        Integer num = 100;
218
+        String exp = arraz.toString(new Integer[] {3,2,1,0,100});
219
+        Integer[] actArr = arraz.insertAtEnd(arr, num);
220
+        String act = arraz.toString(actArr);
221
+        Assert.assertEquals(exp,act);
222
+    }
223
+
224
+    @Test
225
+    public void testSortEvenOdd() {
226
+        Integer[] arr = {3,2,1,0};
227
+        String exp = arraz.toString(new Integer[] {2,0,1,3});
228
+        Integer[] actArr = arraz.sortArrayIntoEvensThenOdds(arr);
229
+        String act = arraz.toString(actArr);
230
+        Assert.assertEquals(exp,act);
231
+    }
232
+
13 233
 
14 234
 }