Michelle DiMarino 6 лет назад
Родитель
Сommit
d182863a79
4 измененных файлов: 123 добавлений и 111 удалений
  1. 64
    44
      .idea/workspace.xml
  2. 4
    0
      src/main/java/MyArrayList.java
  3. 46
    1
      src/main/java/MySet.java
  4. 9
    66
      src/test/java/MySetTest.java

+ 64
- 44
.idea/workspace.xml Просмотреть файл

@@ -2,10 +2,10 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="b4e56f8e-cf07-42ba-a071-f009e3608fb2" name="Default Changelist" comment="">
5
-      <change afterPath="$PROJECT_DIR$/src/main/java/MySet.java" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/src/test/java/MySetTest.java" afterDir="false" />
7 5
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
8 6
       <change beforePath="$PROJECT_DIR$/src/main/java/MyArrayList.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/MyArrayList.java" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/src/main/java/MySet.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/MySet.java" afterDir="false" />
8
+      <change beforePath="$PROJECT_DIR$/src/test/java/MySetTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/MySetTest.java" afterDir="false" />
9 9
     </list>
10 10
     <ignored path="$PROJECT_DIR$/target/" />
11 11
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@@ -18,43 +18,44 @@
18 18
     <session id="-666158232">
19 19
       <usages-collector id="statistics.lifecycle.project">
20 20
         <counts>
21
-          <entry key="project.closed" value="3" />
21
+          <entry key="project.closed" value="5" />
22 22
           <entry key="project.open.time.1" value="1" />
23
+          <entry key="project.open.time.11" value="2" />
23 24
           <entry key="project.open.time.2" value="1" />
24 25
           <entry key="project.open.time.4" value="1" />
25 26
           <entry key="project.open.time.6" value="1" />
26
-          <entry key="project.opened" value="4" />
27
+          <entry key="project.opened" value="6" />
27 28
         </counts>
28 29
       </usages-collector>
29 30
       <usages-collector id="statistics.file.extensions.open">
30 31
         <counts>
31
-          <entry key="java" value="9" />
32
+          <entry key="java" value="10" />
32 33
           <entry key="md" value="1" />
33 34
           <entry key="xml" value="1" />
34 35
         </counts>
35 36
       </usages-collector>
36 37
       <usages-collector id="statistics.file.types.open">
37 38
         <counts>
38
-          <entry key="JAVA" value="9" />
39
+          <entry key="JAVA" value="10" />
39 40
           <entry key="Markdown" value="1" />
40 41
           <entry key="XML" value="1" />
41 42
         </counts>
42 43
       </usages-collector>
43 44
       <usages-collector id="statistics.file.extensions.edit">
44 45
         <counts>
45
-          <entry key="java" value="4243" />
46
+          <entry key="java" value="5045" />
46 47
         </counts>
47 48
       </usages-collector>
48 49
       <usages-collector id="statistics.file.types.edit">
49 50
         <counts>
50
-          <entry key="JAVA" value="4243" />
51
+          <entry key="JAVA" value="5045" />
51 52
         </counts>
52 53
       </usages-collector>
53 54
     </session>
54 55
   </component>
55 56
   <component name="FileEditorManager">
56
-    <leaf>
57
-      <file pinned="false" current-in-tab="true">
57
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
58
+      <file pinned="false" current-in-tab="false">
58 59
         <entry file="file://$PROJECT_DIR$/README.md">
59 60
           <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
60 61
             <state split_layout="SPLIT">
@@ -67,8 +68,8 @@
67 68
       <file pinned="false" current-in-tab="false">
68 69
         <entry file="file://$PROJECT_DIR$/src/test/java/MySetTest.java">
69 70
           <provider selected="true" editor-type-id="text-editor">
70
-            <state relative-caret-position="675">
71
-              <caret line="45" column="29" selection-start-line="45" selection-start-column="29" selection-end-line="45" selection-end-column="29" />
71
+            <state relative-caret-position="74">
72
+              <caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" />
72 73
               <folding>
73 74
                 <element signature="imports" expanded="true" />
74 75
               </folding>
@@ -76,23 +77,32 @@
76 77
           </provider>
77 78
         </entry>
78 79
       </file>
79
-      <file pinned="false" current-in-tab="false">
80
-        <entry file="file://$PROJECT_DIR$/src/test/java/MyArrayListTest.java">
80
+      <file pinned="false" current-in-tab="true">
81
+        <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
81 82
           <provider selected="true" editor-type-id="text-editor">
82
-            <state relative-caret-position="239">
83
-              <caret line="90" column="41" lean-forward="true" selection-start-line="88" selection-start-column="8" selection-end-line="90" selection-end-column="41" />
83
+            <state relative-caret-position="227">
84
+              <caret line="19" column="41" lean-forward="true" selection-start-line="19" selection-start-column="41" selection-end-line="19" selection-end-column="41" />
84 85
               <folding>
85 86
                 <element signature="imports" expanded="true" />
87
+                <element signature="e#151#152#0" expanded="true" />
88
+                <element signature="e#189#190#0" expanded="true" />
89
+                <element signature="e#318#319#0" expanded="true" />
90
+                <element signature="e#345#346#0" expanded="true" />
86 91
               </folding>
87 92
             </state>
88 93
           </provider>
89 94
         </entry>
90 95
       </file>
91 96
       <file pinned="false" current-in-tab="false">
92
-        <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
97
+        <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
93 98
           <provider selected="true" editor-type-id="text-editor">
94
-            <state>
95
-              <caret column="18" selection-start-column="18" selection-end-column="18" />
99
+            <state relative-caret-position="363">
100
+              <caret line="42" column="22" lean-forward="true" selection-start-line="30" selection-start-column="7" selection-end-line="42" selection-end-column="22" />
101
+              <folding>
102
+                <element signature="imports" expanded="true" />
103
+                <element signature="e#275#276#0" expanded="true" />
104
+                <element signature="e#370#371#0" expanded="true" />
105
+              </folding>
96 106
             </state>
97 107
           </provider>
98 108
         </entry>
@@ -115,6 +125,7 @@
115 125
         <option value="$PROJECT_DIR$/src/test/java/MyArrayListTest.java" />
116 126
         <option value="$PROJECT_DIR$/src/main/java/MyArrayList.java" />
117 127
         <option value="$PROJECT_DIR$/src/test/java/MySetTest.java" />
128
+        <option value="$PROJECT_DIR$/src/main/java/MySet.java" />
118 129
       </list>
119 130
     </option>
120 131
   </component>
@@ -135,6 +146,7 @@
135 146
       <foldersAlwaysOnTop value="true" />
136 147
     </navigator>
137 148
     <panes>
149
+      <pane id="PackagesPane" />
138 150
       <pane id="ProjectPane">
139 151
         <subPane>
140 152
           <expand>
@@ -178,13 +190,12 @@
178 190
         </subPane>
179 191
       </pane>
180 192
       <pane id="Scope" />
181
-      <pane id="PackagesPane" />
182 193
     </panes>
183 194
   </component>
184 195
   <component name="PropertiesComponent">
185 196
     <property name="WebServerToolWindowFactoryState" value="false" />
186 197
     <property name="aspect.path.notification.shown" value="true" />
187
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542293259198" />
198
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542386591148" />
188 199
     <property name="last_opened_file_path" value="$PROJECT_DIR$/pom.xml" />
189 200
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
190 201
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
@@ -280,7 +291,9 @@
280 291
       <workItem from="1542220770531" duration="5472000" />
281 292
       <workItem from="1542235718301" duration="7000" />
282 293
       <workItem from="1542240547208" duration="5969000" />
283
-      <workItem from="1542283982047" duration="2540000" />
294
+      <workItem from="1542283982047" duration="2743000" />
295
+      <workItem from="1542303688489" duration="207000" />
296
+      <workItem from="1542384681171" duration="1627000" />
284 297
     </task>
285 298
     <servers />
286 299
   </component>
@@ -317,13 +330,13 @@
317 330
     </history-entry>
318 331
   </component>
319 332
   <component name="TimeTrackingManager">
320
-    <option name="totallyTimeSpent" value="13988000" />
333
+    <option name="totallyTimeSpent" value="16025000" />
321 334
   </component>
322 335
   <component name="ToolWindowManager">
323 336
     <frame x="0" y="23" width="1260" height="708" extended-state="0" />
324 337
     <editor active="true" />
325 338
     <layout>
326
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26190478" />
339
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.27011493" />
327 340
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
328 341
       <window_info id="Image Layers" order="2" />
329 342
       <window_info id="Designer" order="3" />
@@ -373,50 +386,57 @@
373 386
     <entry file="file://$PROJECT_DIR$/../Week5/CR-MesoLabs-Generics-ArrayUtility/src/test/java/com/zipcodewilmington/arrayutility/GetNumberOfOccurrencesTest.java">
374 387
       <provider selected="true" editor-type-id="text-editor" />
375 388
     </entry>
376
-    <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
389
+    <entry file="file://$PROJECT_DIR$/src/test/java/MyArrayListTest.java">
377 390
       <provider selected="true" editor-type-id="text-editor">
378
-        <state relative-caret-position="157">
379
-          <caret line="101" column="23" selection-start-line="101" selection-start-column="23" selection-end-line="101" selection-end-column="23" />
391
+        <state relative-caret-position="1320">
392
+          <caret line="90" column="41" selection-start-line="88" selection-start-column="8" selection-end-line="90" selection-end-column="41" />
380 393
           <folding>
381 394
             <element signature="imports" expanded="true" />
382
-            <element signature="e#191#192#0" expanded="true" />
383
-            <element signature="e#284#285#0" expanded="true" />
384 395
           </folding>
385 396
         </state>
386 397
       </provider>
387 398
     </entry>
388
-    <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
389
-      <provider selected="true" editor-type-id="text-editor">
390
-        <state>
391
-          <caret column="18" selection-start-column="18" selection-end-column="18" />
399
+    <entry file="file://$PROJECT_DIR$/README.md">
400
+      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
401
+        <state split_layout="SPLIT">
402
+          <first_editor />
403
+          <second_editor />
392 404
         </state>
393 405
       </provider>
394 406
     </entry>
395
-    <entry file="file://$PROJECT_DIR$/src/test/java/MyArrayListTest.java">
407
+    <entry file="file://$PROJECT_DIR$/src/test/java/MySetTest.java">
396 408
       <provider selected="true" editor-type-id="text-editor">
397
-        <state relative-caret-position="239">
398
-          <caret line="90" column="41" lean-forward="true" selection-start-line="88" selection-start-column="8" selection-end-line="90" selection-end-column="41" />
409
+        <state relative-caret-position="74">
410
+          <caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" />
399 411
           <folding>
400 412
             <element signature="imports" expanded="true" />
401 413
           </folding>
402 414
         </state>
403 415
       </provider>
404 416
     </entry>
405
-    <entry file="file://$PROJECT_DIR$/src/test/java/MySetTest.java">
417
+    <entry file="file://$PROJECT_DIR$/src/main/java/MyArrayList.java">
406 418
       <provider selected="true" editor-type-id="text-editor">
407
-        <state relative-caret-position="675">
408
-          <caret line="45" column="29" selection-start-line="45" selection-start-column="29" selection-end-line="45" selection-end-column="29" />
419
+        <state relative-caret-position="363">
420
+          <caret line="42" column="22" lean-forward="true" selection-start-line="30" selection-start-column="7" selection-end-line="42" selection-end-column="22" />
409 421
           <folding>
410 422
             <element signature="imports" expanded="true" />
423
+            <element signature="e#275#276#0" expanded="true" />
424
+            <element signature="e#370#371#0" expanded="true" />
411 425
           </folding>
412 426
         </state>
413 427
       </provider>
414 428
     </entry>
415
-    <entry file="file://$PROJECT_DIR$/README.md">
416
-      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
417
-        <state split_layout="SPLIT">
418
-          <first_editor />
419
-          <second_editor />
429
+    <entry file="file://$PROJECT_DIR$/src/main/java/MySet.java">
430
+      <provider selected="true" editor-type-id="text-editor">
431
+        <state relative-caret-position="227">
432
+          <caret line="19" column="41" lean-forward="true" selection-start-line="19" selection-start-column="41" selection-end-line="19" selection-end-column="41" />
433
+          <folding>
434
+            <element signature="imports" expanded="true" />
435
+            <element signature="e#151#152#0" expanded="true" />
436
+            <element signature="e#189#190#0" expanded="true" />
437
+            <element signature="e#318#319#0" expanded="true" />
438
+            <element signature="e#345#346#0" expanded="true" />
439
+          </folding>
420 440
         </state>
421 441
       </provider>
422 442
     </entry>

+ 4
- 0
src/main/java/MyArrayList.java Просмотреть файл

@@ -6,6 +6,10 @@ public class MyArrayList <T> {
6 6
 
7 7
     private T[] array1;
8 8
 
9
+    public MyArrayList(){
10
+
11
+    }
12
+
9 13
     public MyArrayList(T[] array){
10 14
         this.array1 = array;
11 15
 

+ 46
- 1
src/main/java/MySet.java Просмотреть файл

@@ -1,2 +1,47 @@
1
-public class MySet {
1
+import java.lang.reflect.Array;
2
+import java.util.ArrayList;
3
+
4
+public class MySet<T> extends MyArrayList<T>{
5
+
6
+
7
+    private T[] mySetArray;
8
+
9
+    public MySet(){
10
+
11
+    }
12
+
13
+    public MySet(T[] array){
14
+        this.mySetArray = array;
15
+    }
16
+
17
+
18
+
19
+    public T[] add(T value){
20
+        if (mySetArray.contains(value) == false){
21
+            ArrayList<T> arrayWithAdd = new ArrayList<>();
22
+
23
+            for (T element : mySetArray){
24
+                arrayWithAdd.add(element);
25
+            }
26
+
27
+            arrayWithAdd.add(value);
28
+
29
+            T[] objs =  (T[]) Array.newInstance(mySetArray.getClass().getComponentType(), arrayWithAdd.size());
30
+
31
+            mySetArray = arrayWithAdd.toArray(objs);
32
+
33
+
34
+        }
35
+        return mySetArray;
36
+
37
+    }
38
+
39
+    public void addAll(T[] array) {
40
+    }
41
+
42
+    public boolean equals(Object value){
43
+        return false;
44
+    }
45
+
46
+
2 47
 }

+ 9
- 66
src/test/java/MySetTest.java Просмотреть файл

@@ -2,13 +2,16 @@ import org.junit.Assert;
2 2
 import org.junit.Test;
3 3
 
4 4
 public class MySetTest {
5
+    Integer[] arraySet;
6
+    MySet<Integer>  set = new MySet(arraySet);
7
+
5 8
 
6 9
     @Test
7 10
     public void addTest(){
8 11
         int expectedOutput = 6;
9 12
 
10
-        arraySet.add(5);
11
-        int actualOutput = arraySet.size();
13
+        set.add(5);
14
+        int actualOutput = set.size();
12 15
 
13 16
         Assert.assertEquals(expectedOutput, actualOutput);
14 17
 
@@ -17,87 +20,27 @@ public class MySetTest {
17 20
     @Test
18 21
     public void addAllTest(){
19 22
         int expectedOutput = 5;
23
+        Integer[] array2 = {1,2,3,4,5};
20 24
 
21
-        arraySet.addAll(1,2,3,4,5);
22
-        int actualOutput = arraySet.size();
25
+        set.addAll(array2);
26
+        int actualOutput = set.size();
23 27
 
24 28
         Assert.assertEquals(expectedOutput, actualOutput);
25 29
 
26 30
     }
27 31
 
28
-    @Test
29
-    public void clearTest(){
30
-        arraySet.clear();
31
-        boolean actualOutput = arraySet.isEmpty();
32
-
33
-        Assert.assertTrue(actualOutput);
34
-
35
-    }
36 32
 
37
-    @Test
38
-    public void containsTest(){
39
-        boolean actualOutput = arraySet.contains(5);
40
-
41
-        Assert.assertTrue(actualOutput);
42
-
43
-    }
44 33
 
45 34
     @Test
46 35
     public void equalsTest(){
47 36
 
48
-        boolean actualOutput = arraySet.equals(value);
37
+        boolean actualOutput = set.equals();
49 38
 
50 39
         Assert.assertTrue(actualOutput);
51 40
 
52 41
     }
53 42
 
54
-    @Test
55
-    public void hashCodeTest(){
56
-
57
-    }
58
-
59
-    @Test
60
-    public void isEmptyTest(){
61
-        boolean actualOutput = arraySet.isEmpty();
62
-
63
-        Assert.assertFalse(actualOutput);
64
-
65
-    }
66
-
67
-    @Test
68
-    public void iteratorTest(){
69
-
70
-    }
71
-
72
-    @Test
73
-    public void removeTest(){
74
-        int expectedOutput = 4;
75
-
76
-        arraySet.remove(5);
77
-        int actualOutput = arraySet.size();
78
-
79
-        Assert.assertEquals(expectedOutput, actualOutput);
80
-
81
-    }
82
-
83
-    @Test
84
-    public void removeAllTest(){
85
-
86
-    }
87
-
88
-    @Test
89
-    public void sizeTest(){
90
-        int expectedOutput = 5;
91
-
92
-        int actualOutput = arraySet.size();
93 43
 
94
-        Assert.assertEquals(expectedOutput, actualOutput);
95 44
 
96
-    }
97
-
98
-    @Test
99
-    public void toArrayTest(){
100
-
101
-    }
102 45
 
103 46
 }