Nick Satinover před 6 roky
rodič
revize
f1f1b897af

+ 23
- 0
arraz/src/main/java/Arraz.java Zobrazit soubor

@@ -25,4 +25,27 @@ public class Arraz {
25 25
         double sum = sumDoublesOfArray(doublesArr);
26 26
         return sum / doublesArr.length;
27 27
     }
28
+
29
+    public boolean containsValue(int[] intsArr, int findThisInt){
30
+        boolean retBoolean = false;
31
+        for (int i:intsArr) {
32
+            if (i == findThisInt){
33
+                retBoolean = true;
34
+                break;
35
+            }
36
+        }
37
+        return retBoolean;
38
+    }
39
+
40
+    public int[] reverseArray(int[] intsArr){
41
+        int[] retArr = new int[intsArr.length];
42
+        int counter = intsArr.length - 1;
43
+
44
+        for (int i:intsArr) {
45
+            retArr[counter] = i;
46
+            counter--;
47
+        }
48
+
49
+        return retArr;
50
+    }
28 51
 }

+ 7
- 0
arraz/src/main/java/OddEven.java Zobrazit soubor

@@ -0,0 +1,7 @@
1
+public class OddEven {
2
+        private int odds;
3
+        private int evens;
4
+
5
+    public OddEven() {
6
+    }
7
+}

+ 54
- 0
arraz/src/test/java/ArrazTest.java Zobrazit soubor

@@ -115,4 +115,58 @@ public class ArrazTest {
115 115
         //THEN
116 116
         Assert.assertEquals(expected, actual);
117 117
     }
118
+
119
+    @Test
120
+    public void test1containsValue(){
121
+        //GIVEN
122
+        int[] arr = {1, 2, 3, 4, 5};
123
+
124
+        //WHEN
125
+        int test = 3;
126
+        boolean expected = true;
127
+        boolean actual = arraz.containsValue(arr, test);
128
+
129
+        //THEN
130
+        Assert.assertEquals(expected, actual);
131
+    }
132
+
133
+    @Test
134
+    public void test2containsValue(){
135
+        //GIVEN
136
+        int[] arr = {1, 2, 3, 4, 5, 6};
137
+
138
+        //WHEN
139
+        int test = 7;
140
+        boolean expected = false;
141
+        boolean actual = arraz.containsValue(arr, test);
142
+
143
+        //THEN
144
+        Assert.assertEquals(expected, actual);
145
+    }
146
+
147
+    @Test
148
+    public void test1reverseArray(){
149
+        //GIVEN
150
+        int[] arr = {1, 2, 3, 4, 5};
151
+
152
+        //WHEN
153
+        int[] expected = {5, 4, 3, 2, 1};
154
+        int[] actual = arraz.reverseArray(arr);
155
+
156
+        //THEN
157
+        Assert.assertEquals(arr[1], actual[3]);
158
+    }
159
+
160
+    @Test
161
+    public void test2reverseArray(){
162
+        //GIVEN
163
+        int[] arr = {-2, -1, 0, 1};
164
+
165
+        //WHEN
166
+        int[] expected = {1, 0, -1, -2};
167
+        int[] actual = arraz.reverseArray(arr);
168
+
169
+        //THEN
170
+        Assert.assertEquals(arr[0], actual[3]);
171
+    }
118 172
 }