Seth 6 gadus atpakaļ
vecāks
revīzija
1546ea5fb7
3 mainītis faili ar 118 papildinājumiem un 56 dzēšanām
  1. 50
    44
      .idea/workspace.xml
  2. 11
    0
      arraz/src/main/java/Arraz.java
  3. 57
    12
      arraz/src/test/java/ArrazTest.java

+ 50
- 44
.idea/workspace.xml Parādīt failu

2
 <project version="4">
2
 <project version="4">
3
   <component name="ChangeListManager">
3
   <component name="ChangeListManager">
4
     <list default="true" id="3455511b-a100-4bbd-b07c-68f009bc8dbc" name="Default" comment="">
4
     <list default="true" id="3455511b-a100-4bbd-b07c-68f009bc8dbc" name="Default" comment="">
5
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" afterDir="false" />
5
       <change beforePath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/main/java/Arraz.java" afterDir="false" />
7
       <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
6
       <change beforePath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java" afterDir="false" />
8
     </list>
7
     </list>
23
       </usages-collector>
22
       </usages-collector>
24
       <usages-collector id="statistics.file.types.edit">
23
       <usages-collector id="statistics.file.types.edit">
25
         <counts>
24
         <counts>
26
-          <entry key="JAVA" value="7562" />
25
+          <entry key="JAVA" value="8890" />
27
           <entry key="XML" value="3" />
26
           <entry key="XML" value="3" />
28
         </counts>
27
         </counts>
29
       </usages-collector>
28
       </usages-collector>
41
       <file pinned="false" current-in-tab="true">
40
       <file pinned="false" current-in-tab="true">
42
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
41
         <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
43
           <provider selected="true" editor-type-id="text-editor">
42
           <provider selected="true" editor-type-id="text-editor">
44
-            <state relative-caret-position="167">
45
-              <caret line="224" column="52" selection-start-line="224" selection-start-column="52" selection-end-line="224" selection-end-column="52" />
43
+            <state relative-caret-position="372">
44
+              <caret line="294" column="44" selection-start-line="294" selection-start-column="44" selection-end-line="294" selection-end-column="44" />
46
               <folding>
45
               <folding>
47
                 <element signature="imports" expanded="true" />
46
                 <element signature="imports" expanded="true" />
48
                 <element signature="e#4388#4389#0" expanded="true" />
47
                 <element signature="e#4388#4389#0" expanded="true" />
55
       <file pinned="false" current-in-tab="false">
54
       <file pinned="false" current-in-tab="false">
56
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
55
         <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
57
           <provider selected="true" editor-type-id="text-editor">
56
           <provider selected="true" editor-type-id="text-editor">
58
-            <state relative-caret-position="313">
59
-              <caret line="127" lean-forward="true" selection-start-line="127" selection-end-line="127" />
60
-            </state>
61
-          </provider>
62
-        </entry>
63
-      </file>
64
-      <file pinned="false" current-in-tab="false">
65
-        <entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/src.zip!/java/util/Set.java">
66
-          <provider selected="true" editor-type-id="text-editor">
67
-            <state relative-caret-position="386">
68
-              <caret line="189" column="17" selection-start-line="189" selection-start-column="17" selection-end-line="189" selection-end-column="17" />
57
+            <state relative-caret-position="388">
58
+              <caret line="140" lean-forward="true" selection-start-line="140" selection-end-line="140" />
59
+              <folding>
60
+                <element signature="e#3351#3352#0" expanded="true" />
61
+                <element signature="e#3376#3377#0" expanded="true" />
62
+                <element signature="e#3440#3441#0" expanded="true" />
63
+                <element signature="e#3482#3483#0" expanded="true" />
64
+                <element signature="e#3556#3557#0" expanded="true" />
65
+                <element signature="e#3603#3604#0" expanded="true" />
66
+              </folding>
69
             </state>
67
             </state>
70
           </provider>
68
           </provider>
71
         </entry>
69
         </entry>
215
     <property name="GO_FMT" value="false" />
213
     <property name="GO_FMT" value="false" />
216
     <property name="WebServerToolWindowFactoryState" value="false" />
214
     <property name="WebServerToolWindowFactoryState" value="false" />
217
     <property name="aspect.path.notification.shown" value="true" />
215
     <property name="aspect.path.notification.shown" value="true" />
218
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544188738035" />
216
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544190595334" />
219
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
217
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
220
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
218
     <property name="jdk.selected.JAVA_MODULE" value="1.8" />
221
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
219
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
245
       </list>
243
       </list>
246
     </option>
244
     </option>
247
   </component>
245
   </component>
248
-  <component name="RunManager" selected="JUnit.ArrazTest.testRemoveDupesFromArray2">
246
+  <component name="RunManager" selected="JUnit.ArrazTest.testMakeMeAnArrayListFromArray2">
249
     <configuration default="true" type="Applet" factoryName="Applet">
247
     <configuration default="true" type="Applet" factoryName="Applet">
250
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
248
       <option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
251
       <method v="2">
249
       <method v="2">
258
         <option name="Make" enabled="true" />
256
         <option name="Make" enabled="true" />
259
       </method>
257
       </method>
260
     </configuration>
258
     </configuration>
261
-    <configuration name="ArrazTest.testCopyArrayByIterator2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
259
+    <configuration name="ArrazTest.testMakeMeAnArrayFromArrayList1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
262
       <module name="arraz" />
260
       <module name="arraz" />
263
       <option name="PACKAGE_NAME" value="" />
261
       <option name="PACKAGE_NAME" value="" />
264
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
262
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
265
-      <option name="METHOD_NAME" value="testCopyArrayByIterator2" />
263
+      <option name="METHOD_NAME" value="testMakeMeAnArrayFromArrayList1" />
266
       <option name="TEST_OBJECT" value="method" />
264
       <option name="TEST_OBJECT" value="method" />
267
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
265
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
268
       <method v="2">
266
       <method v="2">
269
         <option name="Make" enabled="true" />
267
         <option name="Make" enabled="true" />
270
       </method>
268
       </method>
271
     </configuration>
269
     </configuration>
272
-    <configuration name="ArrazTest.testFindMaxMinOfArray1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
270
+    <configuration name="ArrazTest.testMakeMeAnArrayListFromArray1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
273
       <module name="arraz" />
271
       <module name="arraz" />
274
       <option name="PACKAGE_NAME" value="" />
272
       <option name="PACKAGE_NAME" value="" />
275
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
273
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
276
-      <option name="METHOD_NAME" value="testFindMaxMinOfArray1" />
274
+      <option name="METHOD_NAME" value="testMakeMeAnArrayListFromArray1" />
277
       <option name="TEST_OBJECT" value="method" />
275
       <option name="TEST_OBJECT" value="method" />
278
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
276
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
279
       <method v="2">
277
       <method v="2">
280
         <option name="Make" enabled="true" />
278
         <option name="Make" enabled="true" />
281
       </method>
279
       </method>
282
     </configuration>
280
     </configuration>
283
-    <configuration name="ArrazTest.testFindMaxMinOfArray2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
281
+    <configuration name="ArrazTest.testMakeMeAnArrayListFromArray2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
284
       <module name="arraz" />
282
       <module name="arraz" />
285
       <option name="PACKAGE_NAME" value="" />
283
       <option name="PACKAGE_NAME" value="" />
286
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
284
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
287
-      <option name="METHOD_NAME" value="testFindMaxMinOfArray2" />
285
+      <option name="METHOD_NAME" value="testMakeMeAnArrayListFromArray2" />
288
       <option name="TEST_OBJECT" value="method" />
286
       <option name="TEST_OBJECT" value="method" />
289
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
287
       <option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
290
       <method v="2">
288
       <method v="2">
337
       </method>
335
       </method>
338
     </configuration>
336
     </configuration>
339
     <list>
337
     <list>
340
-      <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
341
-      <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray1" />
342
-      <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray2" />
343
       <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray2" />
338
       <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray2" />
344
       <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray1" />
339
       <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray1" />
340
+      <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayListFromArray1" />
341
+      <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayListFromArray2" />
342
+      <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayFromArrayList1" />
345
     </list>
343
     </list>
346
     <recent_temporary>
344
     <recent_temporary>
347
       <list>
345
       <list>
346
+        <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayListFromArray2" />
347
+        <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayFromArrayList1" />
348
+        <item itemvalue="JUnit.ArrazTest.testMakeMeAnArrayListFromArray1" />
348
         <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray2" />
349
         <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray2" />
349
         <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray1" />
350
         <item itemvalue="JUnit.ArrazTest.testRemoveDupesFromArray1" />
350
-        <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray2" />
351
-        <item itemvalue="JUnit.ArrazTest.testFindMaxMinOfArray1" />
352
-        <item itemvalue="JUnit.ArrazTest.testCopyArrayByIterator2" />
353
       </list>
351
       </list>
354
     </recent_temporary>
352
     </recent_temporary>
355
   </component>
353
   </component>
366
       <workItem from="1543955862749" duration="2347000" />
364
       <workItem from="1543955862749" duration="2347000" />
367
       <workItem from="1543958998826" duration="113000" />
365
       <workItem from="1543958998826" duration="113000" />
368
       <workItem from="1544020724645" duration="762000" />
366
       <workItem from="1544020724645" duration="762000" />
369
-      <workItem from="1544046933389" duration="22466000" />
367
+      <workItem from="1544046933389" duration="24417000" />
370
     </task>
368
     </task>
371
     <task id="LOCAL-00001" summary="readme and docs">
369
     <task id="LOCAL-00001" summary="readme and docs">
372
       <created>1544021313039</created>
370
       <created>1544021313039</created>
379
     <servers />
377
     <servers />
380
   </component>
378
   </component>
381
   <component name="TestHistory">
379
   <component name="TestHistory">
382
-    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 05s.xml">
383
-      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
384
-    </history-entry>
385
-    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 50s.xml">
386
-      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
387
-    </history-entry>
388
-    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 33m 59s.xml">
389
-      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
390
-    </history-entry>
391
     <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 34m 13s.xml">
380
     <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.06 at 18h 34m 13s.xml">
392
       <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
381
       <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
393
     </history-entry>
382
     </history-entry>
409
     <history-entry file="ArrazTest_testRemoveDupesFromArray1 - 2018.12.07 at 08h 15m 32s.xml">
398
     <history-entry file="ArrazTest_testRemoveDupesFromArray1 - 2018.12.07 at 08h 15m 32s.xml">
410
       <configuration name="ArrazTest.testRemoveDupesFromArray1" configurationId="JUnit" />
399
       <configuration name="ArrazTest.testRemoveDupesFromArray1" configurationId="JUnit" />
411
     </history-entry>
400
     </history-entry>
401
+    <history-entry file="ArrazTest_testRemoveDupesFromArray2 - 2018.12.07 at 08h 18m 59s.xml">
402
+      <configuration name="ArrazTest.testRemoveDupesFromArray2" configurationId="JUnit" />
403
+    </history-entry>
404
+    <history-entry file="ArrazTest_testMakeMeAnArrayListFromArray1 - 2018.12.07 at 08h 40m 21s.xml">
405
+      <configuration name="ArrazTest.testMakeMeAnArrayListFromArray1" configurationId="JUnit" />
406
+    </history-entry>
407
+    <history-entry file="ArrazTest_testMakeMeAnArrayListFromArray2 - 2018.12.07 at 08h 40m 23s.xml">
408
+      <configuration name="ArrazTest.testMakeMeAnArrayListFromArray2" configurationId="JUnit" />
409
+    </history-entry>
412
   </component>
410
   </component>
413
   <component name="TimeTrackingManager">
411
   <component name="TimeTrackingManager">
414
-    <option name="totallyTimeSpent" value="25688000" />
412
+    <option name="totallyTimeSpent" value="27639000" />
415
   </component>
413
   </component>
416
   <component name="ToolWindowManager">
414
   <component name="ToolWindowManager">
417
     <frame x="1" y="23" width="1440" height="807" extended-state="0" />
415
     <frame x="1" y="23" width="1440" height="807" extended-state="0" />
521
     </entry>
519
     </entry>
522
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
520
     <entry file="file://$PROJECT_DIR$/arraz/src/main/java/Arraz.java">
523
       <provider selected="true" editor-type-id="text-editor">
521
       <provider selected="true" editor-type-id="text-editor">
524
-        <state relative-caret-position="313">
525
-          <caret line="127" lean-forward="true" selection-start-line="127" selection-end-line="127" />
522
+        <state relative-caret-position="388">
523
+          <caret line="140" lean-forward="true" selection-start-line="140" selection-end-line="140" />
524
+          <folding>
525
+            <element signature="e#3351#3352#0" expanded="true" />
526
+            <element signature="e#3376#3377#0" expanded="true" />
527
+            <element signature="e#3440#3441#0" expanded="true" />
528
+            <element signature="e#3482#3483#0" expanded="true" />
529
+            <element signature="e#3556#3557#0" expanded="true" />
530
+            <element signature="e#3603#3604#0" expanded="true" />
531
+          </folding>
526
         </state>
532
         </state>
527
       </provider>
533
       </provider>
528
     </entry>
534
     </entry>
529
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
535
     <entry file="file://$PROJECT_DIR$/arraz/src/test/java/ArrazTest.java">
530
       <provider selected="true" editor-type-id="text-editor">
536
       <provider selected="true" editor-type-id="text-editor">
531
-        <state relative-caret-position="167">
532
-          <caret line="224" column="52" selection-start-line="224" selection-start-column="52" selection-end-line="224" selection-end-column="52" />
537
+        <state relative-caret-position="372">
538
+          <caret line="294" column="44" selection-start-line="294" selection-start-column="44" selection-end-line="294" selection-end-column="44" />
533
           <folding>
539
           <folding>
534
             <element signature="imports" expanded="true" />
540
             <element signature="imports" expanded="true" />
535
             <element signature="e#4388#4389#0" expanded="true" />
541
             <element signature="e#4388#4389#0" expanded="true" />

+ 11
- 0
arraz/src/main/java/Arraz.java Parādīt failu

126
         return integerSet.toArray(new Integer[0]);
126
         return integerSet.toArray(new Integer[0]);
127
     }
127
     }
128
 
128
 
129
+    public double find2ndLargestValueFromArray(double[] array){
130
+        return 0.0;
131
+    }
132
+
133
+    public List<Integer> makeMeAnArrayListFromArray(Integer[] array){
134
+       return Arrays.asList(array);
135
+    }
136
+
137
+    public Integer[] makeMeAnArrayFromArrayList(List<Integer> list){
138
+        return list.toArray(new Integer[0]);
139
+    }
129
 }
140
 }

+ 57
- 12
arraz/src/test/java/ArrazTest.java Parādīt failu

4
 import org.junit.Before;
4
 import org.junit.Before;
5
 import org.junit.Test;
5
 import org.junit.Test;
6
 
6
 
7
+import java.util.ArrayList;
7
 import java.util.Arrays;
8
 import java.util.Arrays;
9
+import java.util.List;
8
 
10
 
9
 
11
 
10
 public class ArrazTest {
12
 public class ArrazTest {
15
     private int[] arr1;
17
     private int[] arr1;
16
     private int[] arr2;
18
     private int[] arr2;
17
     private double[] double1;
19
     private double[] double1;
20
+    private double[] double2;
18
 
21
 
19
     @Before
22
     @Before
20
     public void before() {
23
     public void before() {
21
         arr1 = new int[]{5, 10, 3, 29, 100};
24
         arr1 = new int[]{5, 10, 3, 29, 100};
22
         arr2 = new int[]{2, 7, 432, 89};
25
         arr2 = new int[]{2, 7, 432, 89};
23
         double1 = new double[] {1.0, 0.5, 3.6, 38.4, 17.3, 62.0, 9.0, 3.375, 0, 3.14159};
26
         double1 = new double[] {1.0, 0.5, 3.6, 38.4, 17.3, 62.0, 9.0, 3.375, 0, 3.14159};
27
+        double2 =  new double[]{6.0, 2.897, 3.1, 654.3, 5.21, 78.9};
24
         testArraz = new Arraz();
28
         testArraz = new Arraz();
25
         oddEven1 = new OddEven(3, 2);
29
         oddEven1 = new OddEven(3, 2);
26
         maxMin = new MaxMin(100,3);
30
         maxMin = new MaxMin(100,3);
237
         Assert.assertArrayEquals(expected, actual);
241
         Assert.assertArrayEquals(expected, actual);
238
     }
242
     }
239
 
243
 
240
-//    @Test
241
-//    public void testFind2ndLargestFromArray1(){
242
-//        double expected = 38.4;
243
-//        double actual = testArraz.find2ndLargestFromArray();
244
-//
245
-//        Assert.assertEquals(expected, actual, .01);
246
-//    }
247
-//
248
-//    @Test
249
-//    public void testFind2ndLargestFromArray2(){
250
-//
251
-//    }
244
+    @Test
245
+    public void testFind2ndLargestFromArray1(){
246
+        double expected = 38.4;
247
+        double actual = testArraz.find2ndLargestValueFromArray(double1);
248
+
249
+        Assert.assertEquals(expected, actual, .01);
250
+    }
251
+
252
+    @Test
253
+    public void testFind2ndLargestFromArray2(){
254
+        double expected = 78.9;
255
+        double actual = testArraz.find2ndLargestValueFromArray(double2);
256
+
257
+        Assert.assertEquals(expected, actual, .01);
258
+    }
259
+
260
+    @Test
261
+    public void testMakeMeAnArrayListFromArray1(){
262
+        List<Integer> expected= new ArrayList<>();
263
+        expected.add(5);
264
+        expected.add(4);
265
+        expected.add(3);
266
+        Integer[] array = new Integer[]{5, 4, 3};
267
+        List<Integer> actual = testArraz.makeMeAnArrayListFromArray(array);
268
+
269
+        Assert.assertEquals(expected, actual);
270
+    }
271
+
272
+    @Test
273
+    public void testMakeMeAnArrayListFromArray2(){
274
+        List<Integer> expected = new ArrayList<>();
275
+        expected.add(100);
276
+        expected.add(37);
277
+        expected.add(10);
278
+        expected.add(67);
279
+        Integer[] array = new Integer[]{100, 37, 10, 67};
280
+        List<Integer> actual = testArraz.makeMeAnArrayListFromArray(array);
281
+
282
+        Assert.assertEquals(expected, actual);
283
+    }
284
+
285
+    @Test
286
+    public void testMakeMeAnArrayFromArrayList1(){
287
+        Integer[] expected = new Integer[]{10, 7, 23, 50};
288
+        List<Integer> list = new ArrayList<>();
289
+        list.add(10);
290
+        list.add(7);
291
+        list.add(23);
292
+        list.add(50);
293
+        Integer[] actual = testArraz.makeMeAnArrayFromArrayList(list);
294
+
295
+        Assert.assertEquals(expected, actual);
296
+    }
252
 }
297
 }