Demetrius Murray 5 anni fa
parent
commit
0ea382bb13

+ 0
- 88
README.md Vedi File

@@ -1,88 +0,0 @@
1
-# ArraysGoneWild
2
-
3
-This is a series of java array problems to prove your array knowledge.
4
-
5
-__You may ONLY use the information in the DocumentationOnArrays folder only...__
6
-
7
-## NO GOOGLE on this lab.
8
-
9
-At this point you should be able to write up these methods without searching for code patterns
10
-on google.
11
-
12
-## NO STACK-OVERFLOW on this lab.
13
-
14
-At this point you should be able to write up these methods without searching for code patterns
15
-on StackOverflow.
16
-
17
-At this point in the cohort, you should be able to glance at the problem, write a couple tests,
18
-nd then implement the method.
19
-
20
-### For each problem.
21
-
22
-For each of these problems, you need to write the method itself, and two tests for each method. 
23
-If the method is named `sumValuesOfArray`, you should write two test methods:
24
-* test1sumValuesOfArray
25
-* test2sumValuesOfArray
26
-
27
-### Problem list
28
-
29
-Write a method in the Arraz class for each of these:
30
-
31
-* sum values of an array of integers `sumValuesOfArray`
32
-* sum values of an array of doubles `sumDoublesOfArray`
33
-* calculate the average value of an integer array - return an integer `averageOfArray`
34
-* calculate the average value of an double array - return an double `doubleAverageOfArray`
35
-* to test if an integer array contains a specific value, pass both array and value as arguments `containsValue`
36
-* reverse an array of integer values `reverseArray`
37
-* find the number of even and odd integers in a given array of integers `getOddEvensOfArray`, return an object of type
38
-```java
39
-public class OddEven{
40
-    public int odds;
41
-    public int evens;
42
-}
43
-```
44
-
45
-* find the index of an array element, pass both array and value as arguments `findIndexOf`
46
-* copy an array by iterating the array `copyArrayByInterator`
47
-* copy an array by looping thru the array `copyArrayByLoop`
48
-* remove a specific element from an array `removeElementFromArray`
49
-* insert an element into an array a specific position `insertIntoArrayAt`
50
-* find the maximum and minimum value of an array `findMaxMinOfArray` return a 
51
-```java
52
-public class MaxMin{
53
-    public int max;
54
-    public int min;
55
-}
56
-```
57
-* remove duplicate elements from an array, return new array `removeDupesFromArray` (make it an array of Integers)
58
-* find the second largest element in an array of Doubles `find2ndLargestValueFromArray`
59
-
60
-* convert an array to ArrayList `makeMeAnArrayListFromArray`
61
-* convert an ArrayList to an array `makeMeAnArrayFromArrayList`
62
-* test the equality of two arrays `check2ArraysForEqual`
63
-* compute the average value of an array of integers except the largest and smallest values (be thinking
64
-of code re-use for this one) `averageArrayWithoutMaxMin`
65
-* check if an array of integers contains two specified elements: 65 and 77, returns a boolean `arrayHas65and77`
66
-* check if the sum of all the 10's in the array is exactly 30. Return false if the condition does not satisfy, otherwise true. `theTotalofTensIs30`
67
-* find smallest and second smallest elements of a given array
68
-
69
-* copy an array of integers, reverse it, and return it. `makeMeACopyPlease`
70
-* remove the last element from an array of integers, return a copy `removeLastItemAndCopy`
71
-* remove the first element from an array of integers, return a copy `removeFirstItemAndCopy`
72
-* insert a new element at the start of an array, return a copy `insertAtStartAndCopy`
73
-* insert a new element at the end of an array, return a copy `insertAtEndAndCopy`
74
-
75
-* separate even and odd numbers of an given array of integers. Put all even numbers first, and then odd numbers `sortArrayIntoEvensThenOdds`
76
-
77
-If you need an array of ints use this one.
78
-```java
79
-int[] spiffyHandyIntArray = new int[] {4,5,102,6,-7,12,-32,92,8};
80
-```
81
-
82
-
83
-If you need an array of Doubles use this one.
84
-```java
85
-Double[] spiffyHandyDoubleArray = new Double[] {1.0, 0.5, 3.6, 38.4, 17.3, 62.0, 9.0, 3.375, 0, 3.14159};
86
-```
87
-
88
-__But, if you don't like these arrays, feel free to make your own.__

+ 1
- 0
arraz/.gitignore Vedi File

@@ -0,0 +1 @@
1
+.idea/

+ 1
- 2
arraz/arraz.iml Vedi File

@@ -5,11 +5,10 @@
5 5
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
6 6
     <content url="file://$MODULE_DIR$">
7 7
       <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8
-      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
9 8
       <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
10 9
       <excludeFolder url="file://$MODULE_DIR$/target" />
11 10
     </content>
12
-    <orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
11
+    <orderEntry type="inheritedJdk" />
13 12
     <orderEntry type="sourceFolder" forTests="false" />
14 13
     <orderEntry type="library" name="Maven: junit:junit:4.0" level="project" />
15 14
   </component>

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

@@ -1,2 +1,238 @@
1
+import help.OddEven;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Arrays;
5
+import java.util.Iterator;
6
+import java.util.List;
7
+
1 8
 public class Arraz {
9
+
10
+    public int sumValuesOfArray(int[] a){
11
+        int sum = 0;
12
+        for (int i : a)
13
+            sum += i;
14
+
15
+        return sum;
16
+    }
17
+
18
+    public double sumDoubleofArray(double[] a){
19
+        double sum = 0;
20
+        for (double i : a)
21
+            sum += i;
22
+
23
+        return sum;
24
+    }
25
+
26
+    public int averageOfArray(int[] a){
27
+        int sum = 0;
28
+        for (int i : a)
29
+            sum+=i;
30
+        return sum/a.length;
31
+    }
32
+
33
+    public double doubleAverageOfArray(double[] a){
34
+        double sum = 0;
35
+        for (double i : a)
36
+            sum+=i;
37
+        return sum/a.length;
38
+    }
39
+
40
+    public boolean containsValue(int[] a, int val){
41
+        for (int i : a)
42
+            if (i == val)
43
+                return true;
44
+        return false;
45
+    }
46
+
47
+    public OddEven oddEven(int[] a){
48
+        int odd = 0;
49
+        int even = 0;
50
+        for (int i : a) {
51
+            if (i % 2 == 0)
52
+                even++;
53
+            else odd++;
54
+        }
55
+
56
+        return new OddEven(odd,even);
57
+    }
58
+
59
+    public Integer findIndexOf(Integer[] a, Integer i){
60
+        for (int x=0; x<a.length; x++){
61
+            if (a[x] == i)
62
+                return x;
63
+        }
64
+        return -1;
65
+    }
66
+
67
+    public Integer[] copyArrayByIterator(Integer[] a){
68
+        List<Integer> l = Arrays.asList(a);
69
+        List<Integer> b = new ArrayList<Integer>();
70
+        Iterator<Integer> it = l.iterator();
71
+        while (it.hasNext()){
72
+            b.add(it.next());
73
+        }
74
+
75
+        return b.toArray(new Integer[0]);
76
+    }
77
+
78
+    public int[] copyArrayByLoop(int[] a){
79
+        int[] b = new int[a.length];
80
+        for (int i=0; i<a.length;i++)
81
+            b[i] = a[i];
82
+        return b;
83
+    }
84
+
85
+    public Integer[] removeElementFromArray(Integer[] a, Integer b){
86
+        int idx = findIndexOf(a,b);
87
+        Integer[] copy = new Integer[a.length -1];
88
+        for (int i=0; i<a.length; i++){
89
+            if (i < idx)
90
+                copy[i] = a[i];
91
+            else if (i > idx)
92
+                copy[i-1] = a[i];
93
+        }
94
+        return copy;
95
+    }
96
+
97
+    public Integer[] removeDupesFromArray(Integer[] a){
98
+        StringBuilder sb = new StringBuilder();
99
+
100
+        for (int i=0; i<a.length; i++)
101
+            for (int j=i+1; j<a.length-1; j++)
102
+                if (a[i].equals(a[j])) {
103
+                    sb.append(a[i]).append("-");
104
+                    break;
105
+                }
106
+
107
+        String[] strArr = sb.toString().split("-");
108
+        for (String str : strArr) {
109
+            a = removeElementFromArray(a, Integer.valueOf(str));
110
+        }
111
+        return a;
112
+    }
113
+
114
+    public Double find2ndLargestValueFromArray(Double[] d){
115
+        Double max = Double.MIN_VALUE;
116
+        Double min = Double.MIN_VALUE;
117
+
118
+        for (int i=0; i<d.length; i++){
119
+            if (d[i] > max){
120
+                min = max;
121
+                max = d[i];
122
+            } else if (d[i] > min && d[i] < max)
123
+                min = d[i];
124
+        }
125
+
126
+        return min;
127
+    }
128
+
129
+    public List<Integer> makeArrayListFromArray(Integer[] a){
130
+        List<Integer> l = Arrays.asList(a);
131
+        return l;
132
+    }
133
+
134
+    public boolean check2ArraysForEqual(Object[] a, Object[] b){
135
+        if (a.length != b.length) return false;
136
+        for (int i=0; i<a.length; i++){
137
+            if (!a[i].equals(b[i]))
138
+                return false;
139
+        }
140
+        return true;
141
+    }
142
+
143
+    public boolean arrayHas65and77(Integer[] a){
144
+        boolean has65 = false;
145
+        boolean has77 = false;
146
+        for (Integer i:a){
147
+            if (i == 65) has65 = true;
148
+            else if (i == 77) has77 = true;
149
+        }
150
+        return has65 && has77;
151
+    }
152
+
153
+    public boolean theTotalofTensIs30(Integer[] a) {
154
+        int count = 0;
155
+        for (Integer i : a)
156
+            if (i == 10)
157
+                count++;
158
+        return count == 3;
159
+    }
160
+
161
+    public Integer[] findTwoSmallest(Integer[] a){
162
+        Integer small = Integer.MAX_VALUE;
163
+        Integer secSmall = Integer.MAX_VALUE;
164
+
165
+        for (int i=0; i<a.length; i++){
166
+            if (a[i] < small){
167
+                secSmall = small;
168
+                small = a[i];
169
+            } else if (a[i] < secSmall && a[i] > small)
170
+                secSmall = a[i];
171
+        }
172
+
173
+        return new Integer[]{small, secSmall};
174
+    }
175
+
176
+    public Integer[] makeMeACopyPlease(Integer[] a){
177
+        Integer[] b = new Integer[a.length];
178
+        int j=0;
179
+        for (int i=a.length-1; i>=0; i--){
180
+            b[j] = a[i];
181
+            j++;
182
+        }
183
+        return b;
184
+    }
185
+
186
+    public Integer[] removeLastItemAndCopy(Integer[] a){
187
+        Integer[] b = new Integer[a.length-1];
188
+        for (int i=0; i<a.length-1; i++){
189
+            b[i] = a[i];
190
+        }
191
+        return b;
192
+    }
193
+
194
+    public Integer[] removeFirstItemAndCopy(Integer[] a){
195
+        Integer[] b = new Integer[a.length-1];
196
+        for (int i=1; i<a.length; i++){
197
+            b[i-1] = a[i];
198
+        }
199
+        return b;
200
+    }
201
+
202
+    public Integer[] insertAtStartAndCopy(Integer[] a, Integer insert){
203
+        Integer[] b = new Integer[a.length+1];
204
+        b[0] = insert;
205
+        for (int i=0; i<a.length; i++)
206
+            b[i+1] = a[i];
207
+        return b;
208
+    }
209
+
210
+    public Integer[] insertAtEndAndCopy(Integer[] a, Integer insert){
211
+        Integer[] b = new Integer[a.length+1];
212
+        for (int i=0; i<a.length; i++)
213
+            b[i] = a[i];
214
+        b[b.length-1] = insert;
215
+        return b;
216
+    }
217
+
218
+    public Integer[] sortArrayIntoEvensThenOdds(Integer[]a){
219
+        StringBuilder evens = new StringBuilder();
220
+        StringBuilder odds = new StringBuilder();
221
+
222
+        for (Integer i : a) {
223
+            if (i % 2 == 0)
224
+                evens.append(i + " ");
225
+            else odds.append(i + " ");
226
+        }
227
+
228
+        evens.append(odds);
229
+        String[] s = evens.toString().split(" ");
230
+        Integer[] split = new Integer[s.length];
231
+
232
+        for (int i=0; i<s.length; i++)
233
+            split[i] = Integer.valueOf(s[i]);
234
+        return split;
235
+    }
236
+
237
+
2 238
 }

+ 27
- 0
arraz/src/main/java/help/OddEven.java Vedi File

@@ -0,0 +1,27 @@
1
+package help;
2
+
3
+public class OddEven {
4
+    public int odd;
5
+    public int even;
6
+
7
+    public OddEven(int odd, int even) {
8
+        this.odd = odd;
9
+        this.even = even;
10
+    }
11
+
12
+    public int getOdd() {
13
+        return odd;
14
+    }
15
+
16
+    public void setOdd(int odd) {
17
+        this.odd = odd;
18
+    }
19
+
20
+    public int getEven() {
21
+        return even;
22
+    }
23
+
24
+    public void setEven(int even) {
25
+        this.even = even;
26
+    }
27
+}

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

@@ -1,5 +1,320 @@
1
-import static org.junit.Assert.*;
1
+import help.OddEven;
2
+import org.junit.Assert;
3
+import org.junit.Test;
4
+
5
+import java.util.List;
2 6
 
3 7
 public class ArrazTest {
8
+    Arraz test = new Arraz();
9
+
10
+    @Test
11
+    public void testSumOfArray_int1(){
12
+        Assert.assertEquals(10, test.sumValuesOfArray(new int[]{4, 3, 2, 1}));
13
+    }
14
+
15
+    @Test
16
+    public void testSumOfArray_int2(){
17
+        Assert.assertEquals(-15, test.sumValuesOfArray(new int[]{-5,20,-30}));
18
+    }
19
+
20
+    @Test
21
+    public void testSumOfArray_double1(){
22
+        Assert.assertEquals(10.5, test.sumDoubleofArray(new double[]{4.0,3,2,1.5}),.1);
23
+    }
24
+
25
+    @Test
26
+    public void testSumOfArray_double2(){
27
+        Assert.assertEquals(0, test.sumDoubleofArray(new double[]{-5.0,20,-15.0}),.1);
28
+    }
29
+
30
+    @Test
31
+    public void testAverageOfArray_int1(){
32
+        Assert.assertEquals(7, test.averageOfArray(new int[]{3,20,-1}));
33
+    }
34
+
35
+    @Test
36
+    public void testAverageOfArray_int2(){
37
+        Assert.assertEquals(29, test.averageOfArray(new int[]{12,50,15,39}));
38
+    }
39
+
40
+    @Test
41
+    public void testDoubleAverageOfArray_double1(){
42
+        Assert.assertEquals(1.0, test.doubleAverageOfArray(new double[]{3,-5,5.0}),.1);
43
+    }
44
+
45
+    @Test
46
+    public void testDoubleAverageOfArray_double2(){
47
+        Assert.assertEquals(12, test.doubleAverageOfArray(new double[]{12,4,20,12}),.1);
48
+    }
49
+
50
+    @Test
51
+    public void testContainsValue1(){
52
+        Assert.assertTrue(test.containsValue(new int[]{1,2,3,4},3));
53
+    }
54
+
55
+    @Test
56
+    public void testContainsValue2(){
57
+        Assert.assertFalse(test.containsValue(new int[]{1,2,3,4},5));
58
+    }
59
+
60
+    @Test
61
+    public void testOddEven1(){
62
+        OddEven oe = test.oddEven(new int[]{1,2,3,4,5});
63
+        Assert.assertEquals(3,oe.getOdd());
64
+    }
65
+
66
+    @Test
67
+    public void testOddEven2(){
68
+        OddEven oe = test.oddEven(new int[]{1,2,3,4,5});
69
+        Assert.assertEquals(2,oe.getEven());
70
+    }
71
+
72
+    @Test
73
+    public void testFindIndexOf1(){
74
+        Assert.assertEquals(2, test.findIndexOf(new Integer[]{1,2,3,4,5},3));
75
+    }
76
+
77
+    @Test
78
+    public void testFindIndexOf2(){
79
+        Assert.assertEquals(-1, test.findIndexOf(new Integer[]{1,2,3,4,5},6));
80
+    }
81
+
82
+    @Test
83
+    public void testCopyArrayByIterator1(){
84
+        Integer[] a = {1,2,3};
85
+        Integer[] b = test.copyArrayByIterator(a);
86
+        Assert.assertEquals(1, b[0]);
87
+    }
88
+
89
+    @Test
90
+    public void testCopyArrayByIterator2(){
91
+        Integer[] a = {1,2,4};
92
+        Integer[] b = test.copyArrayByIterator(a);
93
+        Assert.assertEquals(4, b[2]);
94
+    }
95
+
96
+    @Test
97
+    public void testCopyArrayByLoop(){
98
+        int[] a = {1,2,3};
99
+        int[] b = test.copyArrayByLoop(a);
100
+        Assert.assertEquals(1, b[0]);
101
+    }
102
+
103
+    @Test
104
+    public void testCopyArrayByLoop2(){
105
+        int[] a = {1,2,3};
106
+        int[] b = test.copyArrayByLoop(a);
107
+        Assert.assertEquals(3, b[2]);
108
+    }
109
+
110
+    @Test
111
+    public void testRemoveElementFromArray1(){
112
+        Integer[] a = {1,2,3};
113
+        Integer[] b = test.removeElementFromArray(a,2);
114
+        Assert.assertEquals(3,b[1]);
115
+    }
116
+
117
+    @Test
118
+    public void testRemoveElementFromArray2(){
119
+        Integer[] a = {1,2,3,4,5,6,7};
120
+        Integer[] b = test.removeElementFromArray(a,4);
121
+        Assert.assertEquals(5,b[3]);
122
+    }
123
+
124
+    @Test
125
+    public void testRemoveDupesFromArray(){
126
+        Integer[] a = {1,1,2,3,4};
127
+        Integer[] b = test.removeDupesFromArray(a);
128
+        Assert.assertEquals(4,b.length);
129
+        Assert.assertEquals(2,b[1]);
130
+    }
131
+
132
+    @Test
133
+    public void testRemoveDupesFromArray2(){
134
+        Integer[] a = {1,1,2,3,4,4,5,1,6};
135
+        Integer[] b = test.removeDupesFromArray(a);
136
+        Assert.assertEquals(6,b.length);
137
+        Assert.assertEquals(1,b[4]);
138
+    }
139
+
140
+    @Test
141
+    public void testFind2ndLargest1(){
142
+        Double[] d = {1.0,2.0,3.0,4.0};
143
+        Assert.assertEquals(3.0,test.find2ndLargestValueFromArray(d));
144
+    }
145
+
146
+    @Test
147
+    public void testFind2ndLargest2(){
148
+        Double[] d = {1.0,1.0,2.0,2.0,2.0,2.0};
149
+        Assert.assertEquals(1.0,test.find2ndLargestValueFromArray(d));
150
+    }
151
+
152
+    @Test
153
+    public void testMakeArrayList1(){
154
+        Integer[] a = {1,2,3,4};
155
+        List<Integer> b = test.makeArrayListFromArray(a);
156
+        Assert.assertEquals(4,b.size());
157
+        Assert.assertEquals(4,b.get(3));
158
+    }
159
+
160
+    @Test
161
+    public void testMakeArrayList2(){
162
+        Integer[] a = {1,2,3,4,6};
163
+        List<Integer> b = test.makeArrayListFromArray(a);
164
+        Assert.assertEquals(5,b.size());
165
+        Assert.assertEquals(6,b.get(4));
166
+    }
167
+
168
+    @Test
169
+    public void testCheck2ArraysForEqual1(){
170
+        Integer[] a = {1,2,3,4};
171
+        Integer[] b = {1,2,3,4};
172
+        Assert.assertTrue(test.check2ArraysForEqual(a,b));
173
+    }
174
+
175
+    @Test
176
+    public void testCheck2ArraysForEqual2(){
177
+        Integer[] a = {1,2,3,4};
178
+        Integer[] b = {1,2,3,5};
179
+        Assert.assertFalse(test.check2ArraysForEqual(a,b));
180
+    }
181
+
182
+    @Test
183
+    public void testHas65and77_1(){
184
+        Integer[] a = {1,2,3,4,65};
185
+        Integer[] b = {1,2,3,4,77};
186
+        Integer[] c = {1,2,3,4};
187
+        Assert.assertFalse(test.arrayHas65and77(a));
188
+        Assert.assertFalse(test.arrayHas65and77(b));
189
+        Assert.assertFalse(test.arrayHas65and77(c));
190
+    }
191
+
192
+    @Test
193
+    public void testHas65and77_2(){
194
+        Integer[] a = {1,2,3,4,65,77};
195
+        Assert.assertTrue(test.arrayHas65and77(a));
196
+    }
197
+
198
+    @Test
199
+    public void testTotalofTensIs30_1(){
200
+        Integer[] a = {1,2,10,10,10,10};
201
+        Integer[] b = {1,2,10,10};
202
+        Assert.assertFalse(test.theTotalofTensIs30(a));
203
+        Assert.assertFalse(test.theTotalofTensIs30(b));
204
+    }
205
+
206
+    @Test
207
+    public void testTotalofTensIs30_2(){
208
+        Integer[] a = {1,2,10,10,10};
209
+        Integer[] b = {10,2,10,10};
210
+        Assert.assertTrue(test.theTotalofTensIs30(a));
211
+        Assert.assertTrue(test.theTotalofTensIs30(b));
212
+    }
213
+
214
+    @Test
215
+    public void testFindTwoSmallest1(){
216
+        Integer[] a = {1,2,3,4,5};
217
+        Integer[] b = test.findTwoSmallest(a);
218
+
219
+        Assert.assertEquals(1,b[0]);
220
+        Assert.assertEquals(2,b[1]);
221
+    }
222
+
223
+    @Test
224
+    public void testFindTwoSmallest2(){
225
+        Integer[] a = {1,1,1,2,2,3,4,5};
226
+        Integer[] b = test.findTwoSmallest(a);
227
+
228
+        Assert.assertEquals(1,b[0]);
229
+        Assert.assertEquals(2,b[1]);
230
+    }
231
+
232
+    @Test
233
+    public void testMakeMeACopyPlease1(){
234
+        Integer[] a = {1,2,3,4};
235
+        Integer[] b = {4,3,2,1};
236
+
237
+        Assert.assertEquals(b,test.makeMeACopyPlease(a));
238
+    }
239
+
240
+    @Test
241
+    public void testMakeMeACopyPlease2(){
242
+        Integer[] a = {1,2,3,4,5,1,1};
243
+        Integer[] b = {1,1,5,4,3,2,1};
244
+
245
+        Assert.assertEquals(b,test.makeMeACopyPlease(a));
246
+    }
247
+
248
+    @Test
249
+    public void testRemoveLastItemAndCopy1(){
250
+        Integer[] a = {1,2,3,4,5};
251
+        Integer[] b = {1,2,3,4};
252
+
253
+        Assert.assertEquals(b,test.removeLastItemAndCopy(a));
254
+    }
255
+
256
+    @Test
257
+    public void testRemoveLastItemAndCopy2(){
258
+        Integer[] a = {1,2,3,4,5,6};
259
+        Integer[] b = {1,2,3,4,5};
260
+
261
+        Assert.assertEquals(b,test.removeLastItemAndCopy(a));
262
+    }
263
+
264
+    @Test
265
+    public void testRemoveFirstItemAndCopy1(){
266
+        Integer[] a = {1,2,3,4,5};
267
+        Integer[] b = {2,3,4,5};
268
+
269
+        Assert.assertEquals(b,test.removeFirstItemAndCopy(a));
270
+    }
271
+
272
+
273
+    @Test
274
+    public void testInsertAtStartAndCopy1(){
275
+        Integer[] a = {1,2,3,4,5,6};
276
+        Integer[] b = {5,1,2,3,4,5,6};
277
+
278
+        Assert.assertEquals(b,test.insertAtStartAndCopy(a,5));
279
+    }
280
+
281
+    @Test
282
+    public void testInsertAtStartAndCopy2(){
283
+        Integer[] a = {1,2,3,4,5,6};
284
+        Integer[] b = {6,1,2,3,4,5,6};
285
+
286
+        Assert.assertEquals(b,test.insertAtStartAndCopy(a,6));
287
+    }
288
+
289
+    @Test
290
+    public void testInsertAtEndAndCopy1(){
291
+        Integer[] a = {1,2,3,4,5,6};
292
+        Integer[] b = {1,2,3,4,5,6,12};
293
+
294
+        Assert.assertEquals(b,test.insertAtEndAndCopy(a,12));
295
+    }
296
+
297
+    @Test
298
+    public void testInsertAtEndAndCopy2(){
299
+        Integer[] a = {1,2,6};
300
+        Integer[] b = {1,2,6,13};
301
+
302
+        Assert.assertEquals(b,test.insertAtEndAndCopy(a,13));
303
+    }
304
+
305
+    @Test
306
+    public void testSortArrayIntoEvensThenOdds1(){
307
+        Integer[] a = {4,5,102,6,-7,12,-32,92,8};
308
+        a = test.sortArrayIntoEvensThenOdds(a);
309
+        Integer[] b = {4,102,6,12,-32,92,8,5,-7};
310
+        Assert.assertEquals(b,test.sortArrayIntoEvensThenOdds(a));
311
+    }
4 312
 
313
+    @Test
314
+    public void testSortArrayIntoEvensThenOdds2(){
315
+        Integer[] a = {4,5,102,6,-7,12,-32,92,8,29, 15, 105, -8};
316
+        a = test.sortArrayIntoEvensThenOdds(a);
317
+        Integer[] b = {4,102,6,12,-32,92,8,-8,5,-7,29,15,105};
318
+        Assert.assertEquals(b,test.sortArrayIntoEvensThenOdds(a));
319
+    }
5 320
 }