Nathan Hall 6 yıl önce
ebeveyn
işleme
75e56a0650

+ 51
- 52
arraz/.idea/workspace.xml Dosyayı Görüntüle

@@ -2,7 +2,6 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="81f99a04-35ff-49d0-a7a5-4ed795a161d6" name="Default Changelist" comment="">
5
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6 5
       <change beforePath="$PROJECT_DIR$/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Arraz.java" afterDir="false" />
7 6
       <change beforePath="$PROJECT_DIR$/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/ArrazTest.java" afterDir="false" />
8 7
     </list>
@@ -28,7 +27,7 @@
28 27
       </usages-collector>
29 28
       <usages-collector id="statistics.file.types.edit">
30 29
         <counts>
31
-          <entry key="JAVA" value="5436" />
30
+          <entry key="JAVA" value="5929" />
32 31
         </counts>
33 32
       </usages-collector>
34 33
     </session>
@@ -40,8 +39,8 @@
40 39
           <file pinned="false" current-in-tab="true">
41 40
             <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
42 41
               <provider selected="true" editor-type-id="text-editor">
43
-                <state relative-caret-position="206">
44
-                  <caret line="224" column="23" lean-forward="true" selection-start-line="224" selection-start-column="23" selection-end-line="224" selection-end-column="23" />
42
+                <state relative-caret-position="162">
43
+                  <caret line="153" column="22" selection-start-line="153" selection-start-column="22" selection-end-line="153" selection-end-column="22" />
45 44
                   <folding>
46 45
                     <element signature="e#1659#1668#0" expanded="true" />
47 46
                     <element signature="e#2355#2364#0" expanded="true" />
@@ -71,8 +70,8 @@
71 70
           <file pinned="false" current-in-tab="true">
72 71
             <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
73 72
               <provider selected="true" editor-type-id="text-editor">
74
-                <state relative-caret-position="197">
75
-                  <caret line="292" column="35" lean-forward="true" selection-start-line="292" selection-start-column="35" selection-end-line="292" selection-end-column="35" />
73
+                <state relative-caret-position="352">
74
+                  <caret line="450" column="25" selection-start-line="450" selection-start-column="25" selection-end-line="450" selection-end-column="25" />
76 75
                   <folding>
77 76
                     <element signature="imports" expanded="true" />
78 77
                     <element signature="e#7644#7653#0" expanded="true" />
@@ -94,8 +93,8 @@
94 93
   <component name="IdeDocumentHistory">
95 94
     <option name="CHANGED_PATHS">
96 95
       <list>
97
-        <option value="$PROJECT_DIR$/src/test/java/ArrazTest.java" />
98 96
         <option value="$PROJECT_DIR$/src/main/java/Arraz.java" />
97
+        <option value="$PROJECT_DIR$/src/test/java/ArrazTest.java" />
99 98
       </list>
100 99
     </option>
101 100
   </component>
@@ -106,10 +105,10 @@
106 105
     <sorting>DEFINITION_ORDER</sorting>
107 106
   </component>
108 107
   <component name="ProjectFrameBounds">
109
-    <option name="x" value="21" />
110
-    <option name="y" value="214" />
111
-    <option name="width" value="1280" />
112
-    <option name="height" value="747" />
108
+    <option name="x" value="-298" />
109
+    <option name="y" value="-995" />
110
+    <option name="width" value="1845" />
111
+    <option name="height" value="940" />
113 112
   </component>
114 113
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
115 114
   <component name="ProjectView">
@@ -166,7 +165,7 @@
166 165
   <component name="PropertiesComponent">
167 166
     <property name="WebServerToolWindowFactoryState" value="false" />
168 167
     <property name="aspect.path.notification.shown" value="true" />
169
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544159948022" />
168
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544193603852" />
170 169
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
171 170
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
172 171
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -183,7 +182,7 @@
183 182
       </list>
184 183
     </option>
185 184
   </component>
186
-  <component name="RunManager" selected="JUnit.ArrazTest">
185
+  <component name="RunManager" selected="JUnit.ArrazTest.test2AverageArrayWithoutMaxMin">
187 186
     <configuration name="ArrazTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
188 187
       <module name="arraz" />
189 188
       <option name="PACKAGE_NAME" value="" />
@@ -192,31 +191,31 @@
192 191
         <option name="Make" enabled="true" />
193 192
       </method>
194 193
     </configuration>
195
-    <configuration name="ArrazTest.test2Check2ArraysForEqual" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
194
+    <configuration name="ArrazTest.test2AverageArrayWithoutMaxMin" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
196 195
       <module name="arraz" />
197 196
       <option name="PACKAGE_NAME" value="" />
198 197
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
199
-      <option name="METHOD_NAME" value="test2Check2ArraysForEqual" />
198
+      <option name="METHOD_NAME" value="test2AverageArrayWithoutMaxMin" />
200 199
       <option name="TEST_OBJECT" value="method" />
201 200
       <method v="2">
202 201
         <option name="Make" enabled="true" />
203 202
       </method>
204 203
     </configuration>
205
-    <configuration name="ArrazTest.test2MakeMeAnArrayFromArrayList" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
204
+    <configuration name="ArrazTest.test2Check2ArraysForEqual" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
206 205
       <module name="arraz" />
207 206
       <option name="PACKAGE_NAME" value="" />
208 207
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
209
-      <option name="METHOD_NAME" value="test2MakeMeAnArrayFromArrayList" />
208
+      <option name="METHOD_NAME" value="test2Check2ArraysForEqual" />
210 209
       <option name="TEST_OBJECT" value="method" />
211 210
       <method v="2">
212 211
         <option name="Make" enabled="true" />
213 212
       </method>
214 213
     </configuration>
215
-    <configuration name="ArrazTest.test2MakeMeAnArrayListFromArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
214
+    <configuration name="ArrazTest.testAverageArrayWithoutMaxMin" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
216 215
       <module name="arraz" />
217 216
       <option name="PACKAGE_NAME" value="" />
218 217
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
219
-      <option name="METHOD_NAME" value="test2MakeMeAnArrayListFromArray" />
218
+      <option name="METHOD_NAME" value="testAverageArrayWithoutMaxMin" />
220 219
       <option name="TEST_OBJECT" value="method" />
221 220
       <method v="2">
222 221
         <option name="Make" enabled="true" />
@@ -233,19 +232,19 @@
233 232
       </method>
234 233
     </configuration>
235 234
     <list>
236
-      <item itemvalue="JUnit.ArrazTest.test2MakeMeAnArrayListFromArray" />
237
-      <item itemvalue="JUnit.ArrazTest.test2MakeMeAnArrayFromArrayList" />
238 235
       <item itemvalue="JUnit.ArrazTest.testCheck2ArraysForEqual" />
239 236
       <item itemvalue="JUnit.ArrazTest.test2Check2ArraysForEqual" />
240 237
       <item itemvalue="JUnit.ArrazTest" />
238
+      <item itemvalue="JUnit.ArrazTest.testAverageArrayWithoutMaxMin" />
239
+      <item itemvalue="JUnit.ArrazTest.test2AverageArrayWithoutMaxMin" />
241 240
     </list>
242 241
     <recent_temporary>
243 242
       <list>
243
+        <item itemvalue="JUnit.ArrazTest.test2AverageArrayWithoutMaxMin" />
244
+        <item itemvalue="JUnit.ArrazTest.testAverageArrayWithoutMaxMin" />
244 245
         <item itemvalue="JUnit.ArrazTest" />
245 246
         <item itemvalue="JUnit.ArrazTest.test2Check2ArraysForEqual" />
246 247
         <item itemvalue="JUnit.ArrazTest.testCheck2ArraysForEqual" />
247
-        <item itemvalue="JUnit.ArrazTest.test2MakeMeAnArrayFromArrayList" />
248
-        <item itemvalue="JUnit.ArrazTest.test2MakeMeAnArrayListFromArray" />
249 248
       </list>
250 249
     </recent_temporary>
251 250
   </component>
@@ -259,17 +258,11 @@
259 258
       <option name="number" value="Default" />
260 259
       <option name="presentableId" value="Default" />
261 260
       <updated>1544046001151</updated>
262
-      <workItem from="1544046022231" duration="26398000" />
261
+      <workItem from="1544046022231" duration="29127000" />
263 262
     </task>
264 263
     <servers />
265 264
   </component>
266 265
   <component name="TestHistory">
267
-    <history-entry file="ArrazTest_test2RemoveDupesFromArray - 2018.12.06 at 22h 39m 23s.xml">
268
-      <configuration name="ArrazTest.test2RemoveDupesFromArray" configurationId="JUnit" />
269
-    </history-entry>
270
-    <history-entry file="ArrazTest_testFind2ndLargestValueFromArray - 2018.12.06 at 22h 39m 28s.xml">
271
-      <configuration name="ArrazTest.testFind2ndLargestValueFromArray" configurationId="JUnit" />
272
-    </history-entry>
273 266
     <history-entry file="ArrazTest_testFind2ndLargestValueFromArray - 2018.12.06 at 22h 40m 59s.xml">
274 267
       <configuration name="ArrazTest.testFind2ndLargestValueFromArray" configurationId="JUnit" />
275 268
     </history-entry>
@@ -294,12 +287,18 @@
294 287
     <history-entry file="ArrazTest_test2Check2ArraysForEqual - 2018.12.06 at 23h 47m 25s.xml">
295 288
       <configuration name="ArrazTest.test2Check2ArraysForEqual" configurationId="JUnit" />
296 289
     </history-entry>
290
+    <history-entry file="ArrazTest - 2018.12.07 at 00h 21m 26s.xml">
291
+      <configuration name="ArrazTest" configurationId="JUnit" />
292
+    </history-entry>
293
+    <history-entry file="ArrazTest_testAverageArrayWithoutMaxMin - 2018.12.07 at 09h 37m 22s.xml">
294
+      <configuration name="ArrazTest.testAverageArrayWithoutMaxMin" configurationId="JUnit" />
295
+    </history-entry>
297 296
   </component>
298 297
   <component name="TimeTrackingManager">
299
-    <option name="totallyTimeSpent" value="26398000" />
298
+    <option name="totallyTimeSpent" value="29127000" />
300 299
   </component>
301 300
   <component name="ToolWindowManager">
302
-    <frame x="31" y="130" width="1280" height="747" extended-state="0" />
301
+    <frame x="-298" y="-995" width="1845" height="940" extended-state="0" />
303 302
     <editor active="true" />
304 303
     <layout>
305 304
       <window_info id="Image Layers" />
@@ -307,16 +306,16 @@
307 306
       <window_info id="UI Designer" />
308 307
       <window_info id="Capture Tool" />
309 308
       <window_info id="Favorites" side_tool="true" />
310
-      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.09289176" />
309
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.06378259" />
311 310
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
312
-      <window_info anchor="bottom" id="Messages" weight="0.32594937" />
311
+      <window_info anchor="bottom" id="Messages" weight="0.32484847" />
313 312
       <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
314 313
       <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
315
-      <window_info anchor="bottom" id="Terminal" weight="0.3908228" />
314
+      <window_info anchor="bottom" id="Terminal" weight="0.29939395" />
316 315
       <window_info anchor="bottom" id="Event Log" side_tool="true" />
317 316
       <window_info anchor="bottom" id="Message" order="0" />
318 317
       <window_info anchor="bottom" id="Find" order="1" />
319
-      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.40822786" />
318
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.40727273" />
320 319
       <window_info anchor="bottom" id="Debug" order="3" weight="0.39810428" />
321 320
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
322 321
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -366,24 +365,10 @@
366 365
         </state>
367 366
       </provider>
368 367
     </entry>
369
-    <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
370
-      <provider selected="true" editor-type-id="text-editor">
371
-        <state relative-caret-position="197">
372
-          <caret line="292" column="35" lean-forward="true" selection-start-line="292" selection-start-column="35" selection-end-line="292" selection-end-column="35" />
373
-          <folding>
374
-            <element signature="imports" expanded="true" />
375
-            <element signature="e#7644#7653#0" expanded="true" />
376
-            <element signature="e#8053#8062#0" expanded="true" />
377
-            <element signature="e#8057#8066#0" expanded="true" />
378
-            <element signature="e#8728#8737#0" expanded="true" />
379
-          </folding>
380
-        </state>
381
-      </provider>
382
-    </entry>
383 368
     <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
384 369
       <provider selected="true" editor-type-id="text-editor">
385
-        <state relative-caret-position="206">
386
-          <caret line="224" column="23" lean-forward="true" selection-start-line="224" selection-start-column="23" selection-end-line="224" selection-end-column="23" />
370
+        <state relative-caret-position="162">
371
+          <caret line="153" column="22" selection-start-line="153" selection-start-column="22" selection-end-line="153" selection-end-column="22" />
387 372
           <folding>
388 373
             <element signature="e#1659#1668#0" expanded="true" />
389 374
             <element signature="e#2355#2364#0" expanded="true" />
@@ -405,5 +390,19 @@
405 390
         </state>
406 391
       </provider>
407 392
     </entry>
393
+    <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
394
+      <provider selected="true" editor-type-id="text-editor">
395
+        <state relative-caret-position="352">
396
+          <caret line="450" column="25" selection-start-line="450" selection-start-column="25" selection-end-line="450" selection-end-column="25" />
397
+          <folding>
398
+            <element signature="imports" expanded="true" />
399
+            <element signature="e#7644#7653#0" expanded="true" />
400
+            <element signature="e#8053#8062#0" expanded="true" />
401
+            <element signature="e#8057#8066#0" expanded="true" />
402
+            <element signature="e#8728#8737#0" expanded="true" />
403
+          </folding>
404
+        </state>
405
+      </provider>
406
+    </entry>
408 407
   </component>
409 408
 </project>

+ 24
- 3
arraz/src/main/java/Arraz.java Dosyayı Görüntüle

@@ -143,11 +143,32 @@ public class Arraz {
143 143
         return Arrays.equals(str1, str2);
144 144
     }
145 145
 
146
-    public Integer averageArrayWithoutMaxMin(Integer[] arr1) {
146
+    public int averageArrayWithoutMaxMin(int[] arr1) {
147
+        int max = arr1[0];
148
+        int min = arr1[0];
149
+        int[] arr2 = new int[arr1.length - 2];
150
+        int count = 0;
151
+        int sum = 0;
152
+
153
+
154
+
155
+        for (int i : arr1){
156
+            if (i > max){
157
+                max = i;
158
+            } else {
159
+                min = i;
160
+            }
161
+        }
162
+
163
+        for (int i : arr1) {
164
+            if ( i != max || i != min){
165
+                sum += i;
166
+                count++;
167
+            }
168
+        }
147 169
 
148
-//        findMaxMinOfArray((Double) arr1);
149 170
 
150
-        return null;
171
+        return sum / count;
151 172
     }
152 173
 
153 174
     public class OddEven {

+ 14
- 3
arraz/src/test/java/ArrazTest.java Dosyayı Görüntüle

@@ -435,10 +435,21 @@ public class ArrazTest {
435 435
     @Test
436 436
     public void testAverageArrayWithoutMaxMin(){
437 437
 
438
-        Integer[] arr1 = {1,2,3,4,5};
438
+        int[] arr1 = {1,2,3,4,5};
439 439
 
440
-        Integer expected = 3;
441
-        Integer actual = arraz.averageArrayWithoutMaxMin(arr1);
440
+        int expected = 3;
441
+        int actual = arraz.averageArrayWithoutMaxMin(arr1);
442
+
443
+        Assert.assertEquals(expected, actual);
444
+    }
445
+
446
+    @Test
447
+    public void test2AverageArrayWithoutMaxMin(){
448
+
449
+        int[] arr1 = {1,2,3};
450
+
451
+        int expected = 2;
452
+        int actual = arraz.averageArrayWithoutMaxMin(arr1);
442 453
 
443 454
         Assert.assertEquals(expected, actual);
444 455
     }