Nathan Hall 6 anni fa
parent
commit
c584e127a9
3 ha cambiato i file con 166 aggiunte e 57 eliminazioni
  1. 68
    56
      arraz/.idea/workspace.xml
  2. 36
    0
      arraz/src/main/java/Arraz.java
  3. 62
    1
      arraz/src/test/java/ArrazTest.java

+ 68
- 56
arraz/.idea/workspace.xml Vedi File

@@ -27,7 +27,7 @@
27 27
       </usages-collector>
28 28
       <usages-collector id="statistics.file.types.edit">
29 29
         <counts>
30
-          <entry key="JAVA" value="639" />
30
+          <entry key="JAVA" value="1519" />
31 31
         </counts>
32 32
       </usages-collector>
33 33
     </session>
@@ -39,8 +39,14 @@
39 39
           <file pinned="false" current-in-tab="true">
40 40
             <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
41 41
               <provider selected="true" editor-type-id="text-editor">
42
-                <state relative-caret-position="394">
43
-                  <caret line="32" column="32" selection-start-line="32" selection-start-column="32" selection-end-line="32" selection-end-column="32" />
42
+                <state relative-caret-position="349">
43
+                  <caret line="82" column="4" lean-forward="true" selection-start-line="82" selection-start-column="4" selection-end-line="82" selection-end-column="4" />
44
+                  <folding>
45
+                    <element signature="e#1253#1254#0" expanded="true" />
46
+                    <element signature="e#1288#1289#0" expanded="true" />
47
+                    <element signature="e#1321#1322#0" expanded="true" />
48
+                    <element signature="e#1357#1358#0" expanded="true" />
49
+                  </folding>
44 50
                 </state>
45 51
               </provider>
46 52
             </entry>
@@ -52,8 +58,8 @@
52 58
           <file pinned="false" current-in-tab="true">
53 59
             <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
54 60
               <provider selected="true" editor-type-id="text-editor">
55
-                <state relative-caret-position="244">
56
-                  <caret line="68" column="46" selection-start-line="68" selection-start-column="46" selection-end-line="68" selection-end-column="46" />
61
+                <state relative-caret-position="334">
62
+                  <caret line="151" column="36" selection-start-line="151" selection-start-column="36" selection-end-line="151" selection-end-column="36" />
57 63
                   <folding>
58 64
                     <element signature="imports" expanded="true" />
59 65
                   </folding>
@@ -83,8 +89,8 @@
83 89
     <sorting>DEFINITION_ORDER</sorting>
84 90
   </component>
85 91
   <component name="ProjectFrameBounds">
86
-    <option name="x" value="-236" />
87
-    <option name="y" value="-893" />
92
+    <option name="x" value="-235" />
93
+    <option name="y" value="-917" />
88 94
     <option name="width" value="1781" />
89 95
     <option name="height" value="817" />
90 96
   </component>
@@ -143,7 +149,7 @@
143 149
   <component name="PropertiesComponent">
144 150
     <property name="WebServerToolWindowFactoryState" value="false" />
145 151
     <property name="aspect.path.notification.shown" value="true" />
146
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544047793848" />
152
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1544051412169" />
147 153
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
148 154
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
149 155
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -160,7 +166,7 @@
160 166
       </list>
161 167
     </option>
162 168
   </component>
163
-  <component name="RunManager" selected="JUnit.ArrazTest.test1DoubleAverageOfArray">
169
+  <component name="RunManager" selected="JUnit.ArrazTest">
164 170
     <configuration name="ArrazTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
165 171
       <module name="arraz" />
166 172
       <option name="PACKAGE_NAME" value="" />
@@ -169,60 +175,60 @@
169 175
         <option name="Make" enabled="true" />
170 176
       </method>
171 177
     </configuration>
172
-    <configuration name="ArrazTest.test1AverageOfArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
178
+    <configuration name="ArrazTest.test1ReverseArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
173 179
       <module name="arraz" />
174 180
       <option name="PACKAGE_NAME" value="" />
175 181
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
176
-      <option name="METHOD_NAME" value="test1AverageOfArray" />
182
+      <option name="METHOD_NAME" value="test1ReverseArray" />
177 183
       <option name="TEST_OBJECT" value="method" />
178 184
       <method v="2">
179 185
         <option name="Make" enabled="true" />
180 186
       </method>
181 187
     </configuration>
182
-    <configuration name="ArrazTest.test1DoubleAverageOfArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
188
+    <configuration name="ArrazTest.test2ContainsValue" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
183 189
       <module name="arraz" />
184 190
       <option name="PACKAGE_NAME" value="" />
185 191
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
186
-      <option name="METHOD_NAME" value="test1DoubleAverageOfArray" />
192
+      <option name="METHOD_NAME" value="test2ContainsValue" />
187 193
       <option name="TEST_OBJECT" value="method" />
188 194
       <method v="2">
189 195
         <option name="Make" enabled="true" />
190 196
       </method>
191 197
     </configuration>
192
-    <configuration name="ArrazTest.test2AverageOfArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
198
+    <configuration name="ArrazTest.test2DoubleAverageOfArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
193 199
       <module name="arraz" />
194 200
       <option name="PACKAGE_NAME" value="" />
195 201
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
196
-      <option name="METHOD_NAME" value="test2AverageOfArray" />
202
+      <option name="METHOD_NAME" value="test2DoubleAverageOfArray" />
197 203
       <option name="TEST_OBJECT" value="method" />
198 204
       <method v="2">
199 205
         <option name="Make" enabled="true" />
200 206
       </method>
201 207
     </configuration>
202
-    <configuration name="ArrazTest.test2DoublesOfArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
208
+    <configuration name="ArrazTest.test2ReverseArray" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
203 209
       <module name="arraz" />
204 210
       <option name="PACKAGE_NAME" value="" />
205 211
       <option name="MAIN_CLASS_NAME" value="ArrazTest" />
206
-      <option name="METHOD_NAME" value="test2DoublesOfArray" />
212
+      <option name="METHOD_NAME" value="test2ReverseArray" />
207 213
       <option name="TEST_OBJECT" value="method" />
208 214
       <method v="2">
209 215
         <option name="Make" enabled="true" />
210 216
       </method>
211 217
     </configuration>
212 218
     <list>
219
+      <item itemvalue="JUnit.ArrazTest.test2ContainsValue" />
220
+      <item itemvalue="JUnit.ArrazTest.test1ReverseArray" />
221
+      <item itemvalue="JUnit.ArrazTest.test2ReverseArray" />
213 222
       <item itemvalue="JUnit.ArrazTest" />
214
-      <item itemvalue="JUnit.ArrazTest.test2DoublesOfArray" />
215
-      <item itemvalue="JUnit.ArrazTest.test1AverageOfArray" />
216
-      <item itemvalue="JUnit.ArrazTest.test2AverageOfArray" />
217
-      <item itemvalue="JUnit.ArrazTest.test1DoubleAverageOfArray" />
223
+      <item itemvalue="JUnit.ArrazTest.test2DoubleAverageOfArray" />
218 224
     </list>
219 225
     <recent_temporary>
220 226
       <list>
221
-        <item itemvalue="JUnit.ArrazTest.test1DoubleAverageOfArray" />
222
-        <item itemvalue="JUnit.ArrazTest.test2AverageOfArray" />
223
-        <item itemvalue="JUnit.ArrazTest.test1AverageOfArray" />
224
-        <item itemvalue="JUnit.ArrazTest.test2DoublesOfArray" />
225 227
         <item itemvalue="JUnit.ArrazTest" />
228
+        <item itemvalue="JUnit.ArrazTest.test2DoubleAverageOfArray" />
229
+        <item itemvalue="JUnit.ArrazTest.test2ReverseArray" />
230
+        <item itemvalue="JUnit.ArrazTest.test1ReverseArray" />
231
+        <item itemvalue="JUnit.ArrazTest.test2ContainsValue" />
226 232
       </list>
227 233
     </recent_temporary>
228 234
   </component>
@@ -236,44 +242,44 @@
236 242
       <option name="number" value="Default" />
237 243
       <option name="presentableId" value="Default" />
238 244
       <updated>1544046001151</updated>
239
-      <workItem from="1544046022231" duration="1600000" />
245
+      <workItem from="1544046022231" duration="5261000" />
240 246
     </task>
241 247
     <servers />
242 248
   </component>
243 249
   <component name="TestHistory">
244
-    <history-entry file="ArrazTest - 2018.12.05 at 16h 49m 09s.xml">
245
-      <configuration name="ArrazTest" configurationId="JUnit" />
250
+    <history-entry file="ArrazTest_test1ReverseArray - 2018.12.05 at 17h 24m 39s.xml">
251
+      <configuration name="ArrazTest.test1ReverseArray" configurationId="JUnit" />
246 252
     </history-entry>
247
-    <history-entry file="ArrazTest_test2sumValuesOfArray - 2018.12.05 at 16h 49m 59s.xml">
248
-      <configuration name="ArrazTest.test2sumValuesOfArray" configurationId="JUnit" />
253
+    <history-entry file="ArrazTest_test1ReverseArray - 2018.12.05 at 17h 35m 52s.xml">
254
+      <configuration name="ArrazTest.test1ReverseArray" configurationId="JUnit" />
249 255
     </history-entry>
250
-    <history-entry file="ArrazTest - 2018.12.05 at 16h 57m 11s.xml">
251
-      <configuration name="ArrazTest" configurationId="JUnit" />
256
+    <history-entry file="ArrazTest_test1ReverseArray - 2018.12.05 at 17h 36m 18s.xml">
257
+      <configuration name="ArrazTest.test1ReverseArray" configurationId="JUnit" />
252 258
     </history-entry>
253
-    <history-entry file="ArrazTest - 2018.12.05 at 16h 58m 04s.xml">
254
-      <configuration name="ArrazTest" configurationId="JUnit" />
259
+    <history-entry file="ArrazTest_test2ReverseArray - 2018.12.05 at 17h 40m 35s.xml">
260
+      <configuration name="ArrazTest.test2ReverseArray" configurationId="JUnit" />
255 261
     </history-entry>
256
-    <history-entry file="ArrazTest_test2DoublesOfArray - 2018.12.05 at 16h 59m 00s.xml">
257
-      <configuration name="ArrazTest.test2DoublesOfArray" configurationId="JUnit" />
262
+    <history-entry file="ArrazTest_test2ReverseArray - 2018.12.05 at 17h 41m 55s.xml">
263
+      <configuration name="ArrazTest.test2ReverseArray" configurationId="JUnit" />
258 264
     </history-entry>
259
-    <history-entry file="ArrazTest_test2DoublesOfArray - 2018.12.05 at 16h 59m 33s.xml">
260
-      <configuration name="ArrazTest.test2DoublesOfArray" configurationId="JUnit" />
265
+    <history-entry file="ArrazTest_test2ReverseArray - 2018.12.05 at 17h 42m 17s.xml">
266
+      <configuration name="ArrazTest.test2ReverseArray" configurationId="JUnit" />
261 267
     </history-entry>
262
-    <history-entry file="ArrazTest_test2DoublesOfArray - 2018.12.05 at 16h 59m 52s.xml">
263
-      <configuration name="ArrazTest.test2DoublesOfArray" configurationId="JUnit" />
268
+    <history-entry file="ArrazTest_test2ReverseArray - 2018.12.05 at 17h 50m 11s.xml">
269
+      <configuration name="ArrazTest.test2ReverseArray" configurationId="JUnit" />
264 270
     </history-entry>
265
-    <history-entry file="ArrazTest_test2DoublesOfArray - 2018.12.05 at 17h 00m 27s.xml">
266
-      <configuration name="ArrazTest.test2DoublesOfArray" configurationId="JUnit" />
271
+    <history-entry file="ArrazTest_test2ReverseArray - 2018.12.05 at 17h 55m 19s.xml">
272
+      <configuration name="ArrazTest.test2ReverseArray" configurationId="JUnit" />
267 273
     </history-entry>
268
-    <history-entry file="ArrazTest_test2DoublesOfArray - 2018.12.05 at 17h 01m 14s.xml">
269
-      <configuration name="ArrazTest.test2DoublesOfArray" configurationId="JUnit" />
274
+    <history-entry file="ArrazTest_test2ReverseArray - 2018.12.05 at 17h 56m 34s.xml">
275
+      <configuration name="ArrazTest.test2ReverseArray" configurationId="JUnit" />
270 276
     </history-entry>
271
-    <history-entry file="ArrazTest_test2DoublesOfArray - 2018.12.05 at 17h 01m 30s.xml">
272
-      <configuration name="ArrazTest.test2DoublesOfArray" configurationId="JUnit" />
277
+    <history-entry file="ArrazTest_test2ReverseArray - 2018.12.05 at 17h 56m 47s.xml">
278
+      <configuration name="ArrazTest.test2ReverseArray" configurationId="JUnit" />
273 279
     </history-entry>
274 280
   </component>
275 281
   <component name="TimeTrackingManager">
276
-    <option name="totallyTimeSpent" value="1600000" />
282
+    <option name="totallyTimeSpent" value="5261000" />
277 283
   </component>
278 284
   <component name="ToolWindowManager">
279 285
     <frame x="-236" y="-893" width="1781" height="817" extended-state="0" />
@@ -289,11 +295,11 @@
289 295
       <window_info anchor="bottom" id="Messages" weight="0.32905984" />
290 296
       <window_info anchor="bottom" id="Database Changes" show_stripe_button="false" />
291 297
       <window_info anchor="bottom" id="Version Control" show_stripe_button="false" />
292
-      <window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.32905984" />
298
+      <window_info anchor="bottom" id="Terminal" weight="0.32905984" />
293 299
       <window_info anchor="bottom" id="Event Log" side_tool="true" />
294 300
       <window_info anchor="bottom" id="Message" order="0" />
295 301
       <window_info anchor="bottom" id="Find" order="1" />
296
-      <window_info anchor="bottom" id="Run" order="2" weight="0.32905984" />
302
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32905984" />
297 303
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
298 304
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
299 305
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@@ -316,19 +322,25 @@
316 322
     <option name="myLimit" value="2678400000" />
317 323
   </component>
318 324
   <component name="editorHistoryManager">
319
-    <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
325
+    <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
320 326
       <provider selected="true" editor-type-id="text-editor">
321
-        <state relative-caret-position="394">
322
-          <caret line="32" column="32" selection-start-line="32" selection-start-column="32" selection-end-line="32" selection-end-column="32" />
327
+        <state relative-caret-position="334">
328
+          <caret line="151" column="36" selection-start-line="151" selection-start-column="36" selection-end-line="151" selection-end-column="36" />
329
+          <folding>
330
+            <element signature="imports" expanded="true" />
331
+          </folding>
323 332
         </state>
324 333
       </provider>
325 334
     </entry>
326
-    <entry file="file://$PROJECT_DIR$/src/test/java/ArrazTest.java">
335
+    <entry file="file://$PROJECT_DIR$/src/main/java/Arraz.java">
327 336
       <provider selected="true" editor-type-id="text-editor">
328
-        <state relative-caret-position="244">
329
-          <caret line="68" column="46" selection-start-line="68" selection-start-column="46" selection-end-line="68" selection-end-column="46" />
337
+        <state relative-caret-position="349">
338
+          <caret line="82" column="4" lean-forward="true" selection-start-line="82" selection-start-column="4" selection-end-line="82" selection-end-column="4" />
330 339
           <folding>
331
-            <element signature="imports" expanded="true" />
340
+            <element signature="e#1253#1254#0" expanded="true" />
341
+            <element signature="e#1288#1289#0" expanded="true" />
342
+            <element signature="e#1321#1322#0" expanded="true" />
343
+            <element signature="e#1357#1358#0" expanded="true" />
332 344
           </folding>
333 345
         </state>
334 346
       </provider>

+ 36
- 0
arraz/src/main/java/Arraz.java Vedi File

@@ -47,4 +47,40 @@ public class Arraz {
47 47
     }
48 48
 
49 49
 
50
+    public boolean containsValue(int[] arr, int value) {
51
+
52
+        for (int i : arr){
53
+            if ( i == value){
54
+                return true;
55
+            }
56
+        }
57
+        return false;
58
+    }
59
+
60
+
61
+    public int[] reverseArray(int[] array1) {
62
+        int[] array2 = new int[array1.length];
63
+
64
+        for (int i = 0; i < array1.length; i++){
65
+            array2[array1.length - 1 - i] = array1[i];
66
+        }
67
+
68
+        return array2;
69
+    }
70
+
71
+    public class OddEven{
72
+        public int odds;
73
+        public int evens;
74
+
75
+        public int getOdds() {
76
+            return odds;
77
+        }
78
+
79
+        public int getEvens() {
80
+            return evens;
81
+        }
82
+    }
83
+
84
+
85
+
50 86
 }

+ 62
- 1
arraz/src/test/java/ArrazTest.java Vedi File

@@ -1,6 +1,9 @@
1 1
 import org.junit.Assert;
2 2
 import org.junit.Test;
3 3
 
4
+import java.util.Arrays;
5
+import java.util.Collections;
6
+
4 7
 import static org.junit.Assert.*;
5 8
 
6 9
 public class ArrazTest {
@@ -85,11 +88,69 @@ public class ArrazTest {
85 88
     @Test
86 89
     public void test2DoubleAverageOfArray(){
87 90
 
88
-        double expected = (17 / 5);
91
+        double expected = (17.0 / 5.0);
89 92
         double actual = arraz.doubleAverageOfArray(arr4);
90 93
 
91 94
         Assert.assertEquals(expected, actual);
92 95
 
93 96
     }
94 97
 
98
+    @Test
99
+    public void test1ContainsValue(){
100
+        int value = 4;
101
+
102
+        boolean actual = arraz.containsValue(arr, value);
103
+
104
+        Assert.assertFalse(actual);
105
+    }
106
+
107
+    @Test
108
+    public void test2ContainsValue(){
109
+        int value = 2;
110
+
111
+        boolean actual = arraz.containsValue(arr, value);
112
+
113
+        Assert.assertTrue(actual);
114
+    }
115
+
116
+    int[] array1 = {1,2,3,4,5};
117
+
118
+    @Test
119
+    public void test1ReverseArray(){
120
+
121
+        int[] expected = {5,4,3,2,1};
122
+        int[] actual = arraz.reverseArray(array1);
123
+
124
+        Assert.assertEquals(Arrays.toString(expected), Arrays.toString(actual));
125
+    }
126
+
127
+    int[] array2 = {10,2,4,7,2};
128
+
129
+    @Test
130
+    public void test2ReverseArray(){
131
+
132
+        int[] expected = {2,7,4,2,10};
133
+        int[] actual = arraz.reverseArray(array2);
134
+
135
+        Assert.assertTrue(Arrays.equals(expected, actual));
136
+
137
+    }
138
+
139
+
140
+
141
+    //int[] array1 = {1,2,3,4,5};
142
+
143
+
144
+
145
+    @Test
146
+    public void testGetOddEvensOfArray(){
147
+
148
+
149
+        int[] expected = {1,2,3,4,5};
150
+        int[] actual = arraz.reverseArray(array2);
151
+
152
+
153
+
154
+    }
155
+
95 156
 }