Nathan Hall пре 6 година
родитељ
комит
75e56a0650
3 измењених фајлова са 89 додато и 58 уклоњено
  1. 51
    52
      arraz/.idea/workspace.xml
  2. 24
    3
      arraz/src/main/java/Arraz.java
  3. 14
    3
      arraz/src/test/java/ArrazTest.java

+ 51
- 52
arraz/.idea/workspace.xml Прегледај датотеку

2
 <project version="4">
2
 <project version="4">
3
   <component name="ChangeListManager">
3
   <component name="ChangeListManager">
4
     <list default="true" id="81f99a04-35ff-49d0-a7a5-4ed795a161d6" name="Default Changelist" comment="">
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
       <change beforePath="$PROJECT_DIR$/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Arraz.java" afterDir="false" />
5
       <change beforePath="$PROJECT_DIR$/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Arraz.java" afterDir="false" />
7
       <change beforePath="$PROJECT_DIR$/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/ArrazTest.java" afterDir="false" />
6
       <change beforePath="$PROJECT_DIR$/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/ArrazTest.java" afterDir="false" />
8
     </list>
7
     </list>
28
       </usages-collector>
27
       </usages-collector>
29
       <usages-collector id="statistics.file.types.edit">
28
       <usages-collector id="statistics.file.types.edit">
30
         <counts>
29
         <counts>
31
-          <entry key="JAVA" value="5436" />
30
+          <entry key="JAVA" value="5929" />
32
         </counts>
31
         </counts>
33
       </usages-collector>
32
       </usages-collector>
34
     </session>
33
     </session>
40
           <file pinned="false" current-in-tab="true">
39
           <file pinned="false" current-in-tab="true">
41
             <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
40
             <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
42
               <provider selected="true" editor-type-id="text-editor">
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
                   <folding>
44
                   <folding>
46
                     <element signature="e#1659#1668#0" expanded="true" />
45
                     <element signature="e#1659#1668#0" expanded="true" />
47
                     <element signature="e#2355#2364#0" expanded="true" />
46
                     <element signature="e#2355#2364#0" expanded="true" />
71
           <file pinned="false" current-in-tab="true">
70
           <file pinned="false" current-in-tab="true">
72
             <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
71
             <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
73
               <provider selected="true" editor-type-id="text-editor">
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
                   <folding>
75
                   <folding>
77
                     <element signature="imports" expanded="true" />
76
                     <element signature="imports" expanded="true" />
78
                     <element signature="e#7644#7653#0" expanded="true" />
77
                     <element signature="e#7644#7653#0" expanded="true" />
94
   <component name="IdeDocumentHistory">
93
   <component name="IdeDocumentHistory">
95
     <option name="CHANGED_PATHS">
94
     <option name="CHANGED_PATHS">
96
       <list>
95
       <list>
97
-        <option value="$PROJECT_DIR$/src/test/java/ArrazTest.java" />
98
         <option value="$PROJECT_DIR$/src/main/java/Arraz.java" />
96
         <option value="$PROJECT_DIR$/src/main/java/Arraz.java" />
97
+        <option value="$PROJECT_DIR$/src/test/java/ArrazTest.java" />
99
       </list>
98
       </list>
100
     </option>
99
     </option>
101
   </component>
100
   </component>
106
     <sorting>DEFINITION_ORDER</sorting>
105
     <sorting>DEFINITION_ORDER</sorting>
107
   </component>
106
   </component>
108
   <component name="ProjectFrameBounds">
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
   </component>
112
   </component>
114
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
113
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
115
   <component name="ProjectView">
114
   <component name="ProjectView">
166
   <component name="PropertiesComponent">
165
   <component name="PropertiesComponent">
167
     <property name="WebServerToolWindowFactoryState" value="false" />
166
     <property name="WebServerToolWindowFactoryState" value="false" />
168
     <property name="aspect.path.notification.shown" value="true" />
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
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
169
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
171
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
170
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
172
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
171
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
183
       </list>
182
       </list>
184
     </option>
183
     </option>
185
   </component>
184
   </component>
186
-  <component name="RunManager" selected="JUnit.ArrazTest">
185
+  <component name="RunManager" selected="JUnit.ArrazTest.test2AverageArrayWithoutMaxMin">
187
     <configuration name="ArrazTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
186
     <configuration name="ArrazTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
188
       <module name="arraz" />
187
       <module name="arraz" />
189
       <option name="PACKAGE_NAME" value="" />
188
       <option name="PACKAGE_NAME" value="" />
192
         <option name="Make" enabled="true" />
191
         <option name="Make" enabled="true" />
193
       </method>
192
       </method>
194
     </configuration>
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
       <module name="arraz" />
195
       <module name="arraz" />
197
       <option name="PACKAGE_NAME" value="" />
196
       <option name="PACKAGE_NAME" value="" />
198
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
197
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
199
-      <option name="METHOD_NAME" value="test2Check2ArraysForEqual" />
198
+      <option name="METHOD_NAME" value="test2AverageArrayWithoutMaxMin" />
200
       <option name="TEST_OBJECT" value="method" />
199
       <option name="TEST_OBJECT" value="method" />
201
       <method v="2">
200
       <method v="2">
202
         <option name="Make" enabled="true" />
201
         <option name="Make" enabled="true" />
203
       </method>
202
       </method>
204
     </configuration>
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
       <module name="arraz" />
205
       <module name="arraz" />
207
       <option name="PACKAGE_NAME" value="" />
206
       <option name="PACKAGE_NAME" value="" />
208
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
207
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
209
-      <option name="METHOD_NAME" value="test2MakeMeAnArrayFromArrayList" />
208
+      <option name="METHOD_NAME" value="test2Check2ArraysForEqual" />
210
       <option name="TEST_OBJECT" value="method" />
209
       <option name="TEST_OBJECT" value="method" />
211
       <method v="2">
210
       <method v="2">
212
         <option name="Make" enabled="true" />
211
         <option name="Make" enabled="true" />
213
       </method>
212
       </method>
214
     </configuration>
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
       <module name="arraz" />
215
       <module name="arraz" />
217
       <option name="PACKAGE_NAME" value="" />
216
       <option name="PACKAGE_NAME" value="" />
218
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
217
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
219
-      <option name="METHOD_NAME" value="test2MakeMeAnArrayListFromArray" />
218
+      <option name="METHOD_NAME" value="testAverageArrayWithoutMaxMin" />
220
       <option name="TEST_OBJECT" value="method" />
219
       <option name="TEST_OBJECT" value="method" />
221
       <method v="2">
220
       <method v="2">
222
         <option name="Make" enabled="true" />
221
         <option name="Make" enabled="true" />
233
       </method>
232
       </method>
234
     </configuration>
233
     </configuration>
235
     <list>
234
     <list>
236
-      <item itemvalue="JUnit.ArrazTest.test2MakeMeAnArrayListFromArray" />
237
-      <item itemvalue="JUnit.ArrazTest.test2MakeMeAnArrayFromArrayList" />
238
       <item itemvalue="JUnit.ArrazTest.testCheck2ArraysForEqual" />
235
       <item itemvalue="JUnit.ArrazTest.testCheck2ArraysForEqual" />
239
       <item itemvalue="JUnit.ArrazTest.test2Check2ArraysForEqual" />
236
       <item itemvalue="JUnit.ArrazTest.test2Check2ArraysForEqual" />
240
       <item itemvalue="JUnit.ArrazTest" />
237
       <item itemvalue="JUnit.ArrazTest" />
238
+      <item itemvalue="JUnit.ArrazTest.testAverageArrayWithoutMaxMin" />
239
+      <item itemvalue="JUnit.ArrazTest.test2AverageArrayWithoutMaxMin" />
241
     </list>
240
     </list>
242
     <recent_temporary>
241
     <recent_temporary>
243
       <list>
242
       <list>
243
+        <item itemvalue="JUnit.ArrazTest.test2AverageArrayWithoutMaxMin" />
244
+        <item itemvalue="JUnit.ArrazTest.testAverageArrayWithoutMaxMin" />
244
         <item itemvalue="JUnit.ArrazTest" />
245
         <item itemvalue="JUnit.ArrazTest" />
245
         <item itemvalue="JUnit.ArrazTest.test2Check2ArraysForEqual" />
246
         <item itemvalue="JUnit.ArrazTest.test2Check2ArraysForEqual" />
246
         <item itemvalue="JUnit.ArrazTest.testCheck2ArraysForEqual" />
247
         <item itemvalue="JUnit.ArrazTest.testCheck2ArraysForEqual" />
247
-        <item itemvalue="JUnit.ArrazTest.test2MakeMeAnArrayFromArrayList" />
248
-        <item itemvalue="JUnit.ArrazTest.test2MakeMeAnArrayListFromArray" />
249
       </list>
248
       </list>
250
     </recent_temporary>
249
     </recent_temporary>
251
   </component>
250
   </component>
259
       <option name="number" value="Default" />
258
       <option name="number" value="Default" />
260
       <option name="presentableId" value="Default" />
259
       <option name="presentableId" value="Default" />
261
       <updated>1544046001151</updated>
260
       <updated>1544046001151</updated>
262
-      <workItem from="1544046022231" duration="26398000" />
261
+      <workItem from="1544046022231" duration="29127000" />
263
     </task>
262
     </task>
264
     <servers />
263
     <servers />
265
   </component>
264
   </component>
266
   <component name="TestHistory">
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
     <history-entry file="ArrazTest_testFind2ndLargestValueFromArray - 2018.12.06 at 22h 40m 59s.xml">
266
     <history-entry file="ArrazTest_testFind2ndLargestValueFromArray - 2018.12.06 at 22h 40m 59s.xml">
274
       <configuration name="ArrazTest.testFind2ndLargestValueFromArray" configurationId="JUnit" />
267
       <configuration name="ArrazTest.testFind2ndLargestValueFromArray" configurationId="JUnit" />
275
     </history-entry>
268
     </history-entry>
294
     <history-entry file="ArrazTest_test2Check2ArraysForEqual - 2018.12.06 at 23h 47m 25s.xml">
287
     <history-entry file="ArrazTest_test2Check2ArraysForEqual - 2018.12.06 at 23h 47m 25s.xml">
295
       <configuration name="ArrazTest.test2Check2ArraysForEqual" configurationId="JUnit" />
288
       <configuration name="ArrazTest.test2Check2ArraysForEqual" configurationId="JUnit" />
296
     </history-entry>
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
   </component>
296
   </component>
298
   <component name="TimeTrackingManager">
297
   <component name="TimeTrackingManager">
299
-    <option name="totallyTimeSpent" value="26398000" />
298
+    <option name="totallyTimeSpent" value="29127000" />
300
   </component>
299
   </component>
301
   <component name="ToolWindowManager">
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
     <editor active="true" />
302
     <editor active="true" />
304
     <layout>
303
     <layout>
305
       <window_info id="Image Layers" />
304
       <window_info id="Image Layers" />
307
       <window_info id="UI Designer" />
306
       <window_info id="UI Designer" />
308
       <window_info id="Capture Tool" />
307
       <window_info id="Capture Tool" />
309
       <window_info id="Favorites" side_tool="true" />
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
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
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
       <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
312
       <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
314
       <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
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
       <window_info anchor="bottom" id="Event Log" side_tool="true" />
315
       <window_info anchor="bottom" id="Event Log" side_tool="true" />
317
       <window_info anchor="bottom" id="Message" order="0" />
316
       <window_info anchor="bottom" id="Message" order="0" />
318
       <window_info anchor="bottom" id="Find" order="1" />
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
       <window_info anchor="bottom" id="Debug" order="3" weight="0.39810428" />
319
       <window_info anchor="bottom" id="Debug" order="3" weight="0.39810428" />
321
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
320
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
322
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
321
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
366
         </state>
365
         </state>
367
       </provider>
366
       </provider>
368
     </entry>
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
     <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
368
     <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
384
       <provider selected="true" editor-type-id="text-editor">
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
           <folding>
372
           <folding>
388
             <element signature="e#1659#1668#0" expanded="true" />
373
             <element signature="e#1659#1668#0" expanded="true" />
389
             <element signature="e#2355#2364#0" expanded="true" />
374
             <element signature="e#2355#2364#0" expanded="true" />
405
         </state>
390
         </state>
406
       </provider>
391
       </provider>
407
     </entry>
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
   </component>
407
   </component>
409
 </project>
408
 </project>

+ 24
- 3
arraz/src/main/java/Arraz.java Прегледај датотеку

143
         return Arrays.equals(str1, str2);
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
     public class OddEven {
174
     public class OddEven {

+ 14
- 3
arraz/src/test/java/ArrazTest.java Прегледај датотеку

435
     @Test
435
     @Test
436
     public void testAverageArrayWithoutMaxMin(){
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
         Assert.assertEquals(expected, actual);
454
         Assert.assertEquals(expected, actual);
444
     }
455
     }