Nuridalia.Hernandez 5 年之前
父節點
當前提交
6d26be47a0

+ 18
- 0
src/main/java/rocks/zipcode/io/quiz3/arrays/TicTacToe.java 查看文件

@@ -4,11 +4,28 @@ package rocks.zipcode.io.quiz3.arrays;
4 4
  * @author leon on 09/12/2018.
5 5
  */
6 6
 public class TicTacToe {
7
+    String [][] board;
7 8
 
8 9
     public TicTacToe(String[][] board) {
10
+
11
+
9 12
     }
10 13
 
11 14
     public String[] getRow(Integer value) {
15
+
16
+
17
+
18
+        for (int i = 0; i < board.length; i++) {
19
+            for (int j = 0; j < board.length; j++) {
20
+                 if (i == value) {
21
+
22
+                 }
23
+
24
+
25
+            }
26
+
27
+        }
28
+
12 29
         return null;
13 30
     }
14 31
 
@@ -25,6 +42,7 @@ public class TicTacToe {
25 42
     }
26 43
 
27 44
     public String getWinner() {
45
+
28 46
         return null;
29 47
     }
30 48
 }

+ 8
- 3
src/main/java/rocks/zipcode/io/quiz3/collections/Lab.java 查看文件

@@ -4,21 +4,26 @@ package rocks.zipcode.io.quiz3.collections;
4 4
  * @author leon on 10/12/2018.
5 5
  */
6 6
 public class Lab {
7
+    private String labName;
8
+    private String labStatus;
9
+
7 10
     public Lab() {
8
-        this(null);
11
+        this.labName="";
9 12
     }
10 13
 
11 14
     public Lab(String labName) {
12 15
     }
13 16
 
14 17
     public String getLabStatus() {
15
-        return null;
18
+        return labStatus;
16 19
     }
17 20
 
18 21
     public void setLabStatus(String labStatus) {
22
+        this.labName = labStatus;
19 23
     }
20 24
 
21 25
     public String getName() {
22
-        return null;
26
+
27
+        return labName;
23 28
     }
24 29
 }

+ 17
- 4
src/main/java/rocks/zipcode/io/quiz3/generics/ArrayUtility.java 查看文件

@@ -1,6 +1,7 @@
1 1
 package rocks.zipcode.io.quiz3.generics;
2 2
 
3 3
 import java.util.function.Function;
4
+import java.util.stream.Collectors;
4 5
 
5 6
 /**
6 7
  * @author leon on 09/12/2018.
@@ -17,19 +18,30 @@ public class ArrayUtility<SomeType> {
17 18
 
18 19
 
19 20
     public SomeType findOddOccurringValue() {
21
+        SomeType someType = null;
22
+        for (int i = 0; i <array.length ; i++) {
23
+          if   ( getNumberOfOccurrences(array[i]) %2 !=0 ) {
24
+               someType = array[i];
25
+          }
20 26
 
27
+        }
21 28
 
22 29
 
23 30
 
24 31
 
25
-
26
-
27
-        return null;
32
+        return someType;
28 33
     }
29 34
 
30 35
     public SomeType findEvenOccurringValue() {
36
+        SomeType someType = null;
37
+        for (int i = 0; i <array.length ; i++) {
38
+            if   ( getNumberOfOccurrences(array[i]) %2 ==0 ) {
39
+                someType = array[i];
40
+            }
31 41
 
32
-        return null;
42
+        }
43
+
44
+        return someType;
33 45
     }
34 46
 
35 47
     public Integer getNumberOfOccurrences(SomeType valueToEvaluate) {
@@ -49,6 +61,7 @@ public class ArrayUtility<SomeType> {
49 61
 
50 62
     public SomeType[] filter(Function<SomeType, Boolean> predicate) {
51 63
 
64
+
52 65
         return null;
53 66
     }
54 67
 }

+ 1
- 1
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerGetNumberOfOccurrences.java 查看文件

@@ -48,7 +48,7 @@ public class IntegerGetNumberOfOccurrences {
48 48
         ArrayUtility<Integer> utility = new ArrayUtility<>(array);
49 49
 
50 50
         // when
51
-        Integer actual = utility.findEvenOccurringValue();
51
+        Integer actual = utility.getNumberOfOccurrences(valueToEvaluate);
52 52
 
53 53
         // then
54 54
         Assert.assertEquals(expected, actual);

+ 3
- 3
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFindOddOccurringValueTest.java 查看文件

@@ -16,7 +16,7 @@ public class StringFindOddOccurringValueTest {
16 16
         ArrayUtility<String> utility = new ArrayUtility<>(array);
17 17
 
18 18
         // when
19
-        String actual = utility.findEvenOccurringValue();
19
+        String actual = utility.findOddOccurringValue();
20 20
         Assert.assertEquals(expected, actual);
21 21
     }
22 22
 
@@ -28,7 +28,7 @@ public class StringFindOddOccurringValueTest {
28 28
         ArrayUtility<String> utility = new ArrayUtility<>(array);
29 29
 
30 30
         // when
31
-        String actual = utility.findEvenOccurringValue();
31
+        String actual = utility.findOddOccurringValue();
32 32
         Assert.assertEquals(expected, actual);
33 33
     }
34 34
 
@@ -40,7 +40,7 @@ public class StringFindOddOccurringValueTest {
40 40
         ArrayUtility<String> utility = new ArrayUtility<>(array);
41 41
 
42 42
         // when
43
-        String actual = utility.findEvenOccurringValue();
43
+        String actual = utility.findOddOccurringValue();
44 44
         Assert.assertEquals(expected, actual);
45 45
     }
46 46
 }

+ 1
- 1
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringGetNumberOfOccurrencesTest.java 查看文件

@@ -44,6 +44,6 @@ public class StringGetNumberOfOccurrencesTest {
44 44
 
45 45
         // when
46 46
         Integer actual = utility.getNumberOfOccurrences(stringToEvaluate);
47
-        Assert.assertEquals(stringToEvaluate, actual);
47
+        Assert.assertEquals(expectedd, actual);
48 48
     }
49 49
 }