Kaynağa Gözat

before lunch commit

Michelle DiMarino 6 yıl önce
ebeveyn
işleme
0767aeb6ff

+ 12
- 1
src/main/java/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.java Dosyayı Görüntüle

@@ -5,6 +5,17 @@ package rocks.zipcode.io.quiz3.arrays;
5 5
  */
6 6
 public class SquareArrayAnalyzer {
7 7
     public static Boolean compare(Integer[] input, Integer[] squaredValues) {
8
-        return null;
8
+        boolean containsSquare = false;
9
+        for (int i = 0; i < input.length; i++) {
10
+            int square = input[i] * input[i];
11
+            for (int j = 0; j < input.length;j++){
12
+                if(square == squaredValues[j]){
13
+                    containsSquare = true;
14
+                    break;
15
+                }
16
+            }
17
+
18
+        }
19
+        return containsSquare;
9 20
     }
10 21
 }

+ 21
- 1
src/main/java/rocks/zipcode/io/quiz3/arrays/WaveGenerator.java Dosyayı Görüntüle

@@ -5,6 +5,26 @@ package rocks.zipcode.io.quiz3.arrays;
5 5
  */
6 6
 public class WaveGenerator {
7 7
     public static String[] wave(String str) {
8
-        return null;
8
+
9
+        String[] waveArray = new String[str.length()];
10
+        int index = 0;
11
+
12
+        for (int i = 0; i < str.length(); i++){
13
+            if(i ==0){
14
+                waveArray[index] = Character.toUpperCase(str.charAt(0))+str.substring(1).toLowerCase();
15
+                index++;
16
+            } else if(i > 0 && str.charAt(i) != ' ') {
17
+                waveArray[index] = str.substring(0, i).toLowerCase() +
18
+                        Character.toUpperCase(str.charAt(i)) + str.substring(i + 1).toLowerCase();
19
+                index++;
20
+            }
21
+        }
22
+        return waveArray;
23
+    }
24
+
25
+    public int calculateArraylength(String str){
26
+        String trimmedString = str.trim();
27
+
28
+        return 0;
9 29
     }
10 30
 }

+ 11
- 0
src/main/java/rocks/zipcode/io/quiz3/collections/Lab.java Dosyayı Görüntüle

@@ -1,14 +1,25 @@
1 1
 package rocks.zipcode.io.quiz3.collections;
2 2
 
3
+import java.util.ArrayList;
4
+import java.util.HashMap;
5
+
3 6
 /**
4 7
  * @author leon on 10/12/2018.
5 8
  */
6 9
 public class Lab {
10
+    HashMap<String, String> lab;
11
+    String labName;
12
+    String status = "PENDING";
13
+
7 14
     public Lab() {
8 15
         this(null);
9 16
     }
10 17
 
11 18
     public Lab(String labName) {
19
+        this.lab = new HashMap<>();
20
+        this.labName = labName;
21
+        lab.put(labName, status);
22
+
12 23
     }
13 24
 
14 25
     public String getLabStatus() {

+ 23
- 3
src/main/java/rocks/zipcode/io/quiz3/generics/ArrayUtility.java Dosyayı Görüntüle

@@ -13,18 +13,38 @@ public class ArrayUtility<SomeType> {
13 13
     }
14 14
 
15 15
     public SomeType findOddOccurringValue() {
16
-        return null;
16
+
17
+        SomeType value = null;
18
+        for (int i = 0; i < array.length; i++) {
19
+            if (getNumberOfOccurrences(array[i]) % 2 != 0){
20
+                value = array[i];
21
+            }
22
+        }
23
+        return value;
17 24
     }
18 25
 
19 26
     public SomeType findEvenOccurringValue() {
20
-        return null;
27
+        SomeType value = null;
28
+        for (int i = 0; i < array.length; i++) {
29
+            if (getNumberOfOccurrences(array[i]) % 2 == 0){
30
+                value = array[i];
31
+            }
32
+        }
33
+        return value;
21 34
     }
22 35
 
23 36
     public Integer getNumberOfOccurrences(SomeType valueToEvaluate) {
24
-        return null;
37
+        Integer counter = 0;
38
+        for (int i = 0; i < array.length; i++){
39
+            if (array[i].equals(valueToEvaluate)){
40
+                counter++;
41
+            }
42
+        }
43
+        return counter;
25 44
     }
26 45
 
27 46
     public SomeType[] filter(Function<SomeType, Boolean> predicate) {
47
+
28 48
         return null;
29 49
     }
30 50
 }

+ 3
- 1
src/main/java/rocks/zipcode/io/quiz3/objectorientation/enums/LabStatus.java Dosyayı Görüntüle

@@ -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
+    PENDING,
8
+    INCOMPLETE,
9
+    COMPLETED,
8 10
 }

+ 4
- 2
src/main/java/rocks/zipcode/io/quiz3/objectorientation/enums/RockPaperScissorHandSign.java Dosyayı Görüntüle

@@ -4,9 +4,11 @@ package rocks.zipcode.io.quiz3.objectorientation.enums;
4 4
  * @author leon on 09/12/2018.
5 5
  */
6 6
 public enum RockPaperScissorHandSign {
7
-    ADD_ENUMERATIONS_HERE;
7
+    SCISSOR, PAPER, ROCK;
8
+
9
+
10
+    public RockPaperScissorHandSign getWinner(){
8 11
 
9
-    public RockPaperScissorHandSign getWinner() {
10 12
         return null;
11 13
     }
12 14
 

+ 2
- 2
src/test/java/rocks/zipcode/io/quiz3/fundamentals/stringutils/IsCharacterAtIndex.java Dosyayı Görüntüle

@@ -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
 

+ 1
- 1
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerGetNumberOfOccurrences.java Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -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
 }

+ 2
- 2
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringGetNumberOfOccurrencesTest.java Dosyayı Görüntüle

@@ -37,13 +37,13 @@ public class StringGetNumberOfOccurrencesTest {
37 37
     @Test
38 38
     public void test3() {
39 39
         // given
40
-        Integer expectedd = 7;
40
+        Integer expected = 7;
41 41
         String stringToEvaluate = "Code";
42 42
         String[] array = {"Zip", "Zip", "Zip", "Zip", "Zip", "Zip", stringToEvaluate, stringToEvaluate, stringToEvaluate, stringToEvaluate, "Wilmington", "Wilmington", stringToEvaluate, stringToEvaluate, stringToEvaluate};
43 43
         ArrayUtility<String> utility = new ArrayUtility<>(array);
44 44
 
45 45
         // when
46 46
         Integer actual = utility.getNumberOfOccurrences(stringToEvaluate);
47
-        Assert.assertEquals(stringToEvaluate, actual);
47
+        Assert.assertEquals(expected, actual);
48 48
     }
49 49
 }