Browse Source

{finished MyArrayList}

Jacqueline Joson 6 years ago
parent
commit
ffd3afe2ac
4 changed files with 104 additions and 52 deletions
  1. 83
    41
      .idea/workspace.xml
  2. 16
    9
      src/main/java/MyArrayList.java
  3. 3
    0
      src/main/java/MySet.java
  4. 2
    2
      src/test/java/MyArrayListTest.java

+ 83
- 41
.idea/workspace.xml View File

25
           <entry key="JAVA/" value="2" />
25
           <entry key="JAVA/" value="2" />
26
           <entry key="JAVA/MyArrayList" value="1" />
26
           <entry key="JAVA/MyArrayList" value="1" />
27
           <entry key="MODULES/mdl-generics" value="1" />
27
           <entry key="MODULES/mdl-generics" value="1" />
28
-          <entry key="class" value="3" />
28
+          <entry key="class" value="4" />
29
           <entry key="iml" value="1" />
29
           <entry key="iml" value="1" />
30
-          <entry key="java" value="2" />
30
+          <entry key="java" value="3" />
31
           <entry key="md" value="1" />
31
           <entry key="md" value="1" />
32
         </counts>
32
         </counts>
33
       </usages-collector>
33
       </usages-collector>
34
       <usages-collector id="statistics.file.types.open">
34
       <usages-collector id="statistics.file.types.open">
35
         <counts>
35
         <counts>
36
-          <entry key="CLASS" value="3" />
36
+          <entry key="CLASS" value="4" />
37
           <entry key="IDEA_MODULE" value="1" />
37
           <entry key="IDEA_MODULE" value="1" />
38
-          <entry key="JAVA" value="2" />
38
+          <entry key="JAVA" value="3" />
39
           <entry key="Markdown" value="1" />
39
           <entry key="Markdown" value="1" />
40
           <entry key="UML" value="4" />
40
           <entry key="UML" value="4" />
41
         </counts>
41
         </counts>
42
       </usages-collector>
42
       </usages-collector>
43
       <usages-collector id="statistics.file.extensions.edit">
43
       <usages-collector id="statistics.file.extensions.edit">
44
         <counts>
44
         <counts>
45
-          <entry key="java" value="3930" />
45
+          <entry key="java" value="4322" />
46
           <entry key="txt" value="59" />
46
           <entry key="txt" value="59" />
47
         </counts>
47
         </counts>
48
       </usages-collector>
48
       </usages-collector>
49
       <usages-collector id="statistics.file.types.edit">
49
       <usages-collector id="statistics.file.types.edit">
50
         <counts>
50
         <counts>
51
-          <entry key="JAVA" value="3930" />
51
+          <entry key="JAVA" value="4322" />
52
           <entry key="PLAIN_TEXT" value="59" />
52
           <entry key="PLAIN_TEXT" value="59" />
53
         </counts>
53
         </counts>
54
       </usages-collector>
54
       </usages-collector>
69
       <file pinned="false" current-in-tab="false">
69
       <file pinned="false" current-in-tab="false">
70
         <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
70
         <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
71
           <provider selected="true" editor-type-id="text-editor">
71
           <provider selected="true" editor-type-id="text-editor">
72
-            <state relative-caret-position="217">
73
-              <caret line="78" column="13" lean-forward="true" selection-start-line="78" selection-start-column="13" selection-end-line="78" selection-end-column="13" />
72
+            <state relative-caret-position="335">
73
+              <caret line="89" lean-forward="true" selection-start-line="89" selection-end-line="89" />
74
               <folding>
74
               <folding>
75
                 <element signature="e#67#68#0" expanded="true" />
75
                 <element signature="e#67#68#0" expanded="true" />
76
                 <element signature="e#107#108#0" expanded="true" />
76
                 <element signature="e#107#108#0" expanded="true" />
83
           </provider>
83
           </provider>
84
         </entry>
84
         </entry>
85
       </file>
85
       </file>
86
+      <file pinned="false" current-in-tab="false">
87
+        <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
88
+          <provider selected="true" editor-type-id="text-editor">
89
+            <state relative-caret-position="17">
90
+              <caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
91
+            </state>
92
+          </provider>
93
+        </entry>
94
+      </file>
86
       <file pinned="false" current-in-tab="true">
95
       <file pinned="false" current-in-tab="true">
87
         <entry file="file://$PROJECT_DIR$/src/test/java/MyArrayListTest.java">
96
         <entry file="file://$PROJECT_DIR$/src/test/java/MyArrayListTest.java">
88
           <provider selected="true" editor-type-id="text-editor">
97
           <provider selected="true" editor-type-id="text-editor">
89
-            <state relative-caret-position="254">
90
-              <caret line="134" column="40" lean-forward="true" selection-start-line="134" selection-start-column="40" selection-end-line="134" selection-end-column="40" />
98
+            <state relative-caret-position="148">
99
+              <caret line="129" column="82" lean-forward="true" selection-start-line="129" selection-start-column="82" selection-end-line="129" selection-end-column="82" />
91
               <folding>
100
               <folding>
92
                 <element signature="imports" expanded="true" />
101
                 <element signature="imports" expanded="true" />
93
                 <element signature="e#282#291#0" expanded="true" />
102
                 <element signature="e#282#291#0" expanded="true" />
126
   <component name="FileTemplateManagerImpl">
135
   <component name="FileTemplateManagerImpl">
127
     <option name="RECENT_TEMPLATES">
136
     <option name="RECENT_TEMPLATES">
128
       <list>
137
       <list>
129
-        <option value="Class" />
130
         <option value="JUnit4 Test Class" />
138
         <option value="JUnit4 Test Class" />
139
+        <option value="Class" />
131
       </list>
140
       </list>
132
     </option>
141
     </option>
133
   </component>
142
   </component>
137
   <component name="IdeDocumentHistory">
146
   <component name="IdeDocumentHistory">
138
     <option name="CHANGED_PATHS">
147
     <option name="CHANGED_PATHS">
139
       <list>
148
       <list>
140
-        <option value="$PROJECT_DIR$/src/main/java/MyArrayList.java" />
149
+        <option value="$PROJECT_DIR$/src/main/java/MySet.java" />
141
         <option value="$PROJECT_DIR$/src/test/java/MyArrayListTest.java" />
150
         <option value="$PROJECT_DIR$/src/test/java/MyArrayListTest.java" />
151
+        <option value="$PROJECT_DIR$/src/main/java/MyArrayList.java" />
142
       </list>
152
       </list>
143
     </option>
153
     </option>
144
   </component>
154
   </component>
212
   <component name="PropertiesComponent">
222
   <component name="PropertiesComponent">
213
     <property name="WebServerToolWindowFactoryState" value="false" />
223
     <property name="WebServerToolWindowFactoryState" value="false" />
214
     <property name="aspect.path.notification.shown" value="true" />
224
     <property name="aspect.path.notification.shown" value="true" />
215
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542340110766" />
225
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542386512999" />
216
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
226
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrary" value="JUnit4" />
217
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrarySuperClass.JUnit4" value="" />
227
     <property name="com.intellij.testIntegration.createTest.CreateTestDialog.defaultLibrarySuperClass.JUnit4" value="" />
218
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
228
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
243
       </list>
253
       </list>
244
     </option>
254
     </option>
245
   </component>
255
   </component>
246
-  <component name="RunManager" selected="JUnit.MyArrayListTest.addOverrideTest">
256
+  <component name="RunManager" selected="JUnit.MyArrayListTest">
247
     <configuration name="MyArrayListTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
257
     <configuration name="MyArrayListTest" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
248
       <module name="generics" />
258
       <module name="generics" />
249
       <option name="PACKAGE_NAME" value="" />
259
       <option name="PACKAGE_NAME" value="" />
301
     </list>
311
     </list>
302
     <recent_temporary>
312
     <recent_temporary>
303
       <list>
313
       <list>
314
+        <item itemvalue="JUnit.MyArrayListTest" />
304
         <item itemvalue="JUnit.MyArrayListTest.addOverrideTest" />
315
         <item itemvalue="JUnit.MyArrayListTest.addOverrideTest" />
305
         <item itemvalue="JUnit.MyArrayListTest.containsFalseTest" />
316
         <item itemvalue="JUnit.MyArrayListTest.containsFalseTest" />
306
         <item itemvalue="JUnit.MyArrayListTest.containsTest" />
317
         <item itemvalue="JUnit.MyArrayListTest.containsTest" />
307
-        <item itemvalue="JUnit.MyArrayListTest" />
308
         <item itemvalue="JUnit.MyArrayListTest.isEmptyTest" />
318
         <item itemvalue="JUnit.MyArrayListTest.isEmptyTest" />
309
       </list>
319
       </list>
310
     </recent_temporary>
320
     </recent_temporary>
319
       <option name="number" value="Default" />
329
       <option name="number" value="Default" />
320
       <option name="presentableId" value="Default" />
330
       <option name="presentableId" value="Default" />
321
       <updated>1542236797011</updated>
331
       <updated>1542236797011</updated>
322
-      <workItem from="1542236798436" duration="16476000" />
332
+      <workItem from="1542236798436" duration="20962000" />
323
     </task>
333
     </task>
324
     <servers />
334
     <servers />
325
   </component>
335
   </component>
326
   <component name="TestHistory">
336
   <component name="TestHistory">
327
-    <history-entry file="MyArrayListTest_setTest - 2018.11.15 at 18h 18m 10s.xml">
328
-      <configuration name="MyArrayListTest.setTest" configurationId="JUnit" />
337
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 08h 56m 05s.xml">
338
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
329
     </history-entry>
339
     </history-entry>
330
-    <history-entry file="MyArrayListTest_setTest - 2018.11.15 at 18h 20m 58s.xml">
331
-      <configuration name="MyArrayListTest.setTest" configurationId="JUnit" />
340
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 08h 56m 16s.xml">
341
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
332
     </history-entry>
342
     </history-entry>
333
-    <history-entry file="MyArrayListTest_setTest - 2018.11.15 at 18h 25m 09s.xml">
334
-      <configuration name="MyArrayListTest.setTest" configurationId="JUnit" />
343
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 08h 58m 50s.xml">
344
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
335
     </history-entry>
345
     </history-entry>
336
-    <history-entry file="MyArrayListTest_clearTest - 2018.11.15 at 18h 33m 46s.xml">
337
-      <configuration name="MyArrayListTest.clearTest" configurationId="JUnit" />
346
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 10h 57m 57s.xml">
347
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
338
     </history-entry>
348
     </history-entry>
339
-    <history-entry file="MyArrayListTest_clearTest - 2018.11.15 at 18h 34m 39s.xml">
340
-      <configuration name="MyArrayListTest.clearTest" configurationId="JUnit" />
349
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 10h 58m 04s.xml">
350
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
341
     </history-entry>
351
     </history-entry>
342
-    <history-entry file="MyArrayListTest - 2018.11.15 at 22h 13m 39s.xml">
343
-      <configuration name="MyArrayListTest" configurationId="JUnit" />
352
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 10h 59m 54s.xml">
353
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
344
     </history-entry>
354
     </history-entry>
345
-    <history-entry file="MyArrayListTest_isEmptyTest - 2018.11.15 at 22h 21m 29s.xml">
346
-      <configuration name="MyArrayListTest.isEmptyTest" configurationId="JUnit" />
355
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 11h 00m 33s.xml">
356
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
347
     </history-entry>
357
     </history-entry>
348
-    <history-entry file="MyArrayListTest - 2018.11.15 at 22h 23m 27s.xml">
349
-      <configuration name="MyArrayListTest" configurationId="JUnit" />
358
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 11h 02m 07s.xml">
359
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
350
     </history-entry>
360
     </history-entry>
351
-    <history-entry file="MyArrayListTest_containsTest - 2018.11.15 at 22h 31m 02s.xml">
352
-      <configuration name="MyArrayListTest.containsTest" configurationId="JUnit" />
361
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 11h 02m 10s.xml">
362
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
353
     </history-entry>
363
     </history-entry>
354
-    <history-entry file="MyArrayListTest_containsFalseTest - 2018.11.15 at 22h 31m 53s.xml">
355
-      <configuration name="MyArrayListTest.containsFalseTest" configurationId="JUnit" />
364
+    <history-entry file="MyArrayListTest_addOverrideTest - 2018.11.16 at 11h 35m 04s.xml">
365
+      <configuration name="MyArrayListTest.addOverrideTest" configurationId="JUnit" />
356
     </history-entry>
366
     </history-entry>
357
   </component>
367
   </component>
358
   <component name="TimeTrackingManager">
368
   <component name="TimeTrackingManager">
359
-    <option name="totallyTimeSpent" value="16476000" />
369
+    <option name="totallyTimeSpent" value="20962000" />
360
   </component>
370
   </component>
361
   <component name="ToolWindowManager">
371
   <component name="ToolWindowManager">
362
     <frame x="0" y="23" width="1280" height="712" extended-state="0" />
372
     <frame x="0" y="23" width="1280" height="712" extended-state="0" />
398
   <component name="VcsContentAnnotationSettings">
408
   <component name="VcsContentAnnotationSettings">
399
     <option name="myLimit" value="2678400000" />
409
     <option name="myLimit" value="2678400000" />
400
   </component>
410
   </component>
411
+  <component name="XDebuggerManager">
412
+    <breakpoint-manager>
413
+      <breakpoints>
414
+        <line-breakpoint enabled="true" type="java-method">
415
+          <url>file://$PROJECT_DIR$/src/main/java/MyArrayList.java</url>
416
+          <line>71</line>
417
+          <properties class="MyArrayList" method="add">
418
+            <option name="EMULATED" value="true" />
419
+          </properties>
420
+          <option name="timeStamp" value="9" />
421
+        </line-breakpoint>
422
+      </breakpoints>
423
+    </breakpoint-manager>
424
+  </component>
401
   <component name="editorHistoryManager">
425
   <component name="editorHistoryManager">
402
     <entry file="file://$PROJECT_DIR$/generics.iml">
426
     <entry file="file://$PROJECT_DIR$/generics.iml">
403
       <provider selected="true" editor-type-id="text-editor" />
427
       <provider selected="true" editor-type-id="text-editor" />
497
         </state>
521
         </state>
498
       </provider>
522
       </provider>
499
     </entry>
523
     </entry>
524
+    <entry file="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/org/junit/Assert.class">
525
+      <provider selected="true" editor-type-id="text-editor">
526
+        <state relative-caret-position="94">
527
+          <caret line="333" selection-start-line="333" selection-end-line="333" />
528
+          <folding>
529
+            <element signature="e#8323#8324#0" expanded="true" />
530
+            <element signature="e#8383#8384#0" expanded="true" />
531
+          </folding>
532
+        </state>
533
+      </provider>
534
+    </entry>
535
+    <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
536
+      <provider selected="true" editor-type-id="text-editor">
537
+        <state relative-caret-position="17">
538
+          <caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
539
+        </state>
540
+      </provider>
541
+    </entry>
500
     <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
542
     <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
501
       <provider selected="true" editor-type-id="text-editor">
543
       <provider selected="true" editor-type-id="text-editor">
502
-        <state relative-caret-position="217">
503
-          <caret line="78" column="13" lean-forward="true" selection-start-line="78" selection-start-column="13" selection-end-line="78" selection-end-column="13" />
544
+        <state relative-caret-position="335">
545
+          <caret line="89" lean-forward="true" selection-start-line="89" selection-end-line="89" />
504
           <folding>
546
           <folding>
505
             <element signature="e#67#68#0" expanded="true" />
547
             <element signature="e#67#68#0" expanded="true" />
506
             <element signature="e#107#108#0" expanded="true" />
548
             <element signature="e#107#108#0" expanded="true" />
514
     </entry>
556
     </entry>
515
     <entry file="file://$PROJECT_DIR$/src/test/java/MyArrayListTest.java">
557
     <entry file="file://$PROJECT_DIR$/src/test/java/MyArrayListTest.java">
516
       <provider selected="true" editor-type-id="text-editor">
558
       <provider selected="true" editor-type-id="text-editor">
517
-        <state relative-caret-position="254">
518
-          <caret line="134" column="40" lean-forward="true" selection-start-line="134" selection-start-column="40" selection-end-line="134" selection-end-column="40" />
559
+        <state relative-caret-position="148">
560
+          <caret line="129" column="82" lean-forward="true" selection-start-line="129" selection-start-column="82" selection-end-line="129" selection-end-column="82" />
519
           <folding>
561
           <folding>
520
             <element signature="imports" expanded="true" />
562
             <element signature="imports" expanded="true" />
521
             <element signature="e#282#291#0" expanded="true" />
563
             <element signature="e#282#291#0" expanded="true" />

+ 16
- 9
src/main/java/MyArrayList.java View File

68
            return theArray.length;
68
            return theArray.length;
69
         }
69
         }
70
 
70
 
71
-//        @Override
72
-//        public void add(int index, T elementToAdd) {
73
-//            T [] newArray = (T[]) new Object[theArray.length + 1];
74
-//            for (int i = 0; i < theArray.length; i++) {
75
-//                newArray[i] = theArray[i];
76
-//                if (i == theArray.length-1) {
77
-//                  newArray[i] = elementToAdd;
71
+
72
+        public void add(int index, T elementToAdd) {
73
+            T[] newArray = (T[]) new Object[theArray.length + 1];
74
+//            int track = 0;
75
+            for (int i = 0; i < theArray.length; i++) {
76
+                newArray[i] = theArray[i];
77
+                if (i == index) {
78
+                    set(i, elementToAdd);
79
+                    i = i+1;
80
+                }
81
+            }
82
+//                if (i == index) {
83
+//                    newArray[track] = elementToAdd;
78
 //                }
84
 //                }
85
+//                newArray[track] = theArray[i];
86
+//                track++;
79
 //            }
87
 //            }
80
-//        } Make a super or abstract class of AbstractList??
81
-
88
+        }
82
 }
89
 }

+ 3
- 0
src/main/java/MySet.java View File

1
+public class MySet <T, E> extends MyArrayList {
2
+
3
+}

+ 2
- 2
src/test/java/MyArrayListTest.java View File

130
         MyArrayList<Integer> myArrayList = new MyArrayList<>(testOverrideAddInts);
130
         MyArrayList<Integer> myArrayList = new MyArrayList<>(testOverrideAddInts);
131
         //when
131
         //when
132
         myArrayList.add(1, 2);
132
         myArrayList.add(1, 2);
133
-        boolean hasBeenAdded = myArrayList.contains(2);
133
+        int actual = myArrayList.get(1);
134
         //then
134
         //then
135
-        Assert.assertTrue(hasBeenAdded);
135
+        Assert.assertEquals(2, actual);
136
     }
136
     }
137
 }
137
 }