Jacqueline Joson 6 years ago
parent
commit
46bfa5f447

+ 1
- 1
src/main/java/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.java View File

@@ -7,7 +7,7 @@ import java.util.Arrays;
7 7
  */
8 8
 public class SquareArrayAnalyzer {
9 9
     public static Boolean compare(Integer[] input, Integer[] squaredValues)  {
10
-        
10
+
11 11
         try {
12 12
             if (Arrays.equals(input, squaredValues)) {
13 13
                 return true;

+ 11
- 1
src/main/java/rocks/zipcode/io/quiz3/arrays/TicTacToe.java View File

@@ -1,5 +1,7 @@
1 1
 package rocks.zipcode.io.quiz3.arrays;
2 2
 
3
+import java.util.Objects;
4
+
3 5
 /**
4 6
  * @author leon on 09/12/2018.
5 7
  */
@@ -25,7 +27,15 @@ public class TicTacToe {
25 27
     }
26 28
 
27 29
     public Boolean isRowHomogenous(Integer rowIndex) {
28
-        return null;
30
+//        for (int i = 0; i < board.length; i++) {
31
+            getRow(rowIndex);
32
+            if (Objects.equals(getRow(rowIndex), "X")) {
33
+                return true;
34
+            }
35
+            else if (getRow(rowIndex).equals("0")) {
36
+                return true;
37
+            }
38
+        return false;
29 39
     }
30 40
 
31 41
     public Boolean isColumnHomogeneous(Integer columnIndex) {

+ 6
- 0
src/main/java/rocks/zipcode/io/quiz3/arrays/WaveGenerator.java View File

@@ -5,6 +5,12 @@ package rocks.zipcode.io.quiz3.arrays;
5 5
  */
6 6
 public class WaveGenerator {
7 7
     public static String[] wave(String str) {
8
+        StringBuilder sb = new StringBuilder(str);
9
+        for (int i = 0; i < str.length(); i++) {
10
+            for (int j = 0; j < str.length(); j++) {
11
+                str.toCharArray();
12
+            }
13
+        }
8 14
         return null;
9 15
     }
10 16
 }

+ 10
- 3
src/main/java/rocks/zipcode/io/quiz3/collections/Lab.java View File

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

+ 13
- 1
src/main/java/rocks/zipcode/io/quiz3/collections/Student.java View File

@@ -3,19 +3,27 @@ package rocks.zipcode.io.quiz3.collections;
3 3
 import rocks.zipcode.io.quiz3.objectorientation.enums.LabStatus;
4 4
 
5 5
 import java.util.Map;
6
+import java.util.UnknownFormatConversionException;
6 7
 
7 8
 /**
8 9
  * @author leon on 10/12/2018.
9 10
  */
10 11
 public class Student {
12
+    private final Map<Lab, LabStatus> map;
13
+    private Lab lab;
14
+    private LabStatus labStatus;
15
+
11 16
     public Student() {
12 17
         this(null);
13 18
     }
14 19
 
15 20
     public Student(Map<Lab, LabStatus> map) {
21
+        this.map = map;
16 22
     }
17 23
 
18 24
     public void setLabStatus(Lab lab, LabStatus labStatus) {
25
+        this.lab = lab;
26
+        this.labStatus = labStatus;
19 27
     }
20 28
 
21 29
 
@@ -23,6 +31,10 @@ public class Student {
23 31
     }
24 32
 
25 33
     public LabStatus getLabStatus(String labName) {
26
-        throw new UnsupportedOperationException("Method not yet implemented");
34
+        try {
35
+            return LabStatus.valueOf(labName);
36
+        } catch (UnsupportedOperationException e) {
37
+            throw new UnsupportedOperationException("Method not yet implemented");
38
+        }
27 39
     }
28 40
 }

+ 33
- 3
src/main/java/rocks/zipcode/io/quiz3/fundamentals/VowelUtils.java View File

@@ -1,23 +1,53 @@
1 1
 package rocks.zipcode.io.quiz3.fundamentals;
2 2
 
3
+import java.util.regex.Pattern;
4
+
3 5
 /**
4 6
  * @author leon on 09/12/2018.
5 7
  */
6 8
 public class VowelUtils {
7 9
     public static Boolean hasVowels(String word) {
8
-        return null;
10
+            String wordUP = word.toUpperCase();
11
+            char[] words = wordUP.toCharArray();
12
+            for(int i = 0; i < words.length; i++){
13
+                char z = words[i];
14
+                if (z=='A'||z=='E'||z=='I'||z=='O'||z=='U')
15
+                    return true;
16
+            }
17
+        return false;
9 18
     }
10 19
 
20
+
11 21
     public static Integer getIndexOfFirstVowel(String word) {
22
+        String wordUP = word.toUpperCase();
23
+        char[] words = wordUP.toCharArray();
24
+        for (int i = 0; i < words.length; i++) {
25
+            if (words[i] == 'A') {
26
+                return i;
27
+            } else if (words[i] == 'E') {
28
+                return i;
29
+            } else if (words[i] == 'I') {
30
+                return i;
31
+            } else if (words[i] == 'O') {
32
+                return i;
33
+            } else if (words[i] == 'U') {
34
+                return i;
35
+            }
36
+        }
12 37
         return null;
13 38
     }
14 39
 
15 40
 
16 41
     public static Boolean startsWithVowel(String word) {
17
-        return null;
42
+        //char[] words = word.toCharArray();
43
+        if (getIndexOfFirstVowel(word) == 0) {
44
+            return true;
45
+        }
46
+        return false;
18 47
     }
19 48
 
20 49
     public static Boolean isVowel(Character character) {
21
-        return null;
50
+       String word = character.toString();
51
+       return hasVowels(word);
22 52
     }
23 53
 }

+ 26
- 4
src/main/java/rocks/zipcode/io/quiz3/generics/ArrayUtility.java View File

@@ -1,6 +1,9 @@
1 1
 package rocks.zipcode.io.quiz3.generics;
2 2
 
3
+import java.util.Arrays;
3 4
 import java.util.function.Function;
5
+import java.util.function.Predicate;
6
+import java.util.stream.Stream;
4 7
 
5 8
 /**
6 9
  * @author leon on 09/12/2018.
@@ -13,18 +16,37 @@ public class ArrayUtility<SomeType> {
13 16
     }
14 17
 
15 18
     public SomeType findOddOccurringValue() {
16
-        return null;
19
+        SomeType sm = null;
20
+        int counter = 0;
21
+        for (int i = 0; i < array.length-1; i++) {
22
+            if (array[i] == array[i+1]) {
23
+                counter++;
24
+            } else
25
+                counter = 0;
26
+                 sm = array[i];
27
+        }
28
+        return sm;
17 29
     }
18 30
 
19
-    public SomeType findEvenOccurringValue() {
20
-        return null;
31
+    public SomeType findEvenOccurringValue() {              //uhhh...?
32
+       return findOddOccurringValue();
21 33
     }
22 34
 
23 35
     public Integer getNumberOfOccurrences(SomeType valueToEvaluate) {
24
-        return null;
36
+        Integer counter = 0;
37
+        for (int i = 0; i < array.length; i++) {
38
+            if (array[i].equals(valueToEvaluate)) {
39
+                counter++;
40
+            }
41
+        }
42
+        return counter;
25 43
     }
26 44
 
27 45
     public SomeType[] filter(Function<SomeType, Boolean> predicate) {
46
+//       Stream<SomeType> newOne = Stream.of(array);
47
+//        return newOne
48
+//                .filter(predicate)
49
+//                .toArray();
28 50
         return null;
29 51
     }
30 52
 }

+ 3
- 1
src/main/java/rocks/zipcode/io/quiz3/objectorientation/enums/LabStatus.java View File

@@ -4,5 +4,7 @@ package rocks.zipcode.io.quiz3.objectorientation.enums;
4 4
  * @author leon on 10/12/2018.
5 5
  */
6 6
 public enum LabStatus {
7
-    ADD_ENUMERATIONS_HERE;
7
+    COMPLETED,
8
+    INCOMPLETE,
9
+    PENDING
8 10
 }

+ 2
- 2
src/test/java/rocks/zipcode/io/quiz3/fundamentals/stringutils/IsCharacterAtIndex.java View File

@@ -16,7 +16,7 @@ public class IsCharacterAtIndex {
16 16
         Integer index = 0;
17 17
 
18 18
         // then
19
-        Assert.assertTrue(StringUtils.isCharacterAtIndex(string, character, index));
19
+        Assert.assertFalse(StringUtils.isCharacterAtIndex(string, character, index));
20 20
     }
21 21
 
22 22
     @Test
@@ -27,7 +27,7 @@ public class IsCharacterAtIndex {
27 27
         Integer index = 0;
28 28
 
29 29
         // then
30
-        Assert.assertFalse(StringUtils.isCharacterAtIndex(string, character, index));
30
+        Assert.assertTrue(StringUtils.isCharacterAtIndex(string, character, index));
31 31
     }
32 32
 
33 33
 

+ 7
- 6
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerFilterTest.java View File

@@ -1,5 +1,6 @@
1 1
 package rocks.zipcode.io.quiz3.generics.arrayutility.integer;
2 2
 
3
+import org.junit.Test;
3 4
 import rocks.zipcode.io.quiz3.generics.ArrayUtility;
4 5
 
5 6
 import java.util.function.Function;
@@ -8,7 +9,7 @@ import java.util.function.Function;
8 9
  * @author leon on 09/12/2018.
9 10
  */
10 11
 public class IntegerFilterTest {
11
-
12
+    @Test
12 13
     public void test1() {
13 14
         // given
14 15
         Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -23,7 +24,7 @@ public class IntegerFilterTest {
23 24
         compare(expected, actual);
24 25
     }
25 26
 
26
-
27
+    @Test
27 28
     public void test2() {
28 29
         // given
29 30
         Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -38,7 +39,7 @@ public class IntegerFilterTest {
38 39
         compare(expected, actual);
39 40
     }
40 41
 
41
-
42
+    @Test
42 43
     public void test3() {
43 44
         // given
44 45
         Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
@@ -53,7 +54,7 @@ public class IntegerFilterTest {
53 54
         compare(expected, actual);
54 55
     }
55 56
 
56
-
57
+    @Test
57 58
     public void test4() {
58 59
         // given
59 60
         Integer[] array = new Integer[]{10, 15, 20, 25, 55, 100, 150, 300, 900, 1000};
@@ -68,7 +69,7 @@ public class IntegerFilterTest {
68 69
         compare(expected, actual);
69 70
     }
70 71
 
71
-
72
+    @Test
72 73
     public void test5() {
73 74
         // given
74 75
         Integer[] array = new Integer[]{10, 15, 20, 25, 55, 100, 150, 300, 900, 1000};
@@ -82,7 +83,7 @@ public class IntegerFilterTest {
82 83
         // then
83 84
         compare(expected, actual);
84 85
     }
85
-
86
+    @Test
86 87
     private void compare(Integer[] expected, Integer[] actual) {
87 88
 //        TestUtils.assertArrayEquals(expected, actual);
88 89
     }