Nathan Hall 6 years ago
parent
commit
0308ad559a

+ 25
- 14
src/main/java/rocks/zipcode/io/quiz3/arrays/WaveGenerator.java View File

@@ -1,27 +1,38 @@
1 1
 package rocks.zipcode.io.quiz3.arrays;
2 2
 
3
+import rocks.zipcode.io.quiz3.fundamentals.StringUtils;
4
+
3 5
 /**
4 6
  * @author leon on 09/12/2018.
5 7
  */
6 8
 public class WaveGenerator {
7 9
     public static String[] wave(String str) {
8 10
         String[] s = new String[str.length()];
9
-        for (String s1 : s){
10
-            s1 = str;
11
-            System.out.println(s1);
12
-        }
13
-
14
-        String big = "";
15
-
16
-        for (int j = 0; j < s.length; j++) {
17
-            for (int i = 0; i < str.length() ; i++) {
18
-                s[i].toLowerCase();
19
-                if (i == j){
20
-                    String.valueOf(s[i].charAt(j)).toUpperCase();
21
-                }
11
+        for (int j = 0; j < str.length(); j++) {
12
+            for (int i = 0; i < str.length(); i++) {
13
+                s[i] = str.toLowerCase();
14
+                s[i] = s[i].substring(0,i) + s[i].substring(i,i+1).toUpperCase() + s[i].substring(i+1);
22 15
             }
23 16
         }
24
-
25 17
         return s;
26 18
     }
19
+
20
+
21
+//        String big = "";
22
+//
23
+//        for (int j = 0; j < s.length; j++) {
24
+//            for (int i = 0; i < str.length() ; i++) {
25
+//                if (i == j){
26
+//                   // String.valueOf(s[j].charAt(j)).toUpperCase();
27
+//                    big = String.valueOf(s[j].charAt(j));
28
+//                    big.toUpperCase();
29
+//                    System.out.println(big);
30
+//                }
31
+//            }
32
+//        }
33
+//
34
+//        return s;
35
+
36
+
37
+//&& String.valueOf(s[j].charAt(i)).matches("[A-Za-z]")
27 38
 }

+ 13
- 4
src/main/java/rocks/zipcode/io/quiz3/collections/Lab.java View File

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

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

@@ -8,14 +8,31 @@ import java.util.Map;
8 8
  * @author leon on 10/12/2018.
9 9
  */
10 10
 public class Student {
11
+    private Map<Lab, LabStatus> map;
12
+    private Lab lab;
13
+    private LabStatus labStatus;
14
+
11 15
     public Student() {
12
-        this(null);
16
+        this.labStatus = labStatus;
17
+    }
18
+
19
+    public Student(Map<Lab, LabStatus> map, Lab lab, LabStatus labStatus) {
20
+        this.map = map;
21
+        this.lab = lab;
22
+        this.labStatus = labStatus;
13 23
     }
14 24
 
25
+    //    public Student() {
26
+//        this(null);
27
+//    }
28
+
15 29
     public Student(Map<Lab, LabStatus> map) {
30
+        this.map = map;
16 31
     }
17 32
 
18 33
     public void setLabStatus(Lab lab, LabStatus labStatus) {
34
+        this.lab = lab;
35
+        this.labStatus = labStatus;
19 36
     }
20 37
 
21 38
 

+ 54
- 1
src/main/java/rocks/zipcode/io/quiz3/generics/ArrayUtility.java View File

@@ -1,5 +1,7 @@
1 1
 package rocks.zipcode.io.quiz3.generics;
2 2
 
3
+import java.util.HashMap;
4
+import java.util.Map;
3 5
 import java.util.function.Function;
4 6
 
5 7
 /**
@@ -7,20 +9,71 @@ import java.util.function.Function;
7 9
  */
8 10
 public class ArrayUtility<SomeType> {
9 11
     private final SomeType[] array;
12
+    private Integer value;
13
+    Map<SomeType, Integer> map = new HashMap<>();
14
+
15
+    public SomeType[] getArray() {
16
+        return array;
17
+    }
18
+
19
+    public Integer getValue() {
20
+        return value;
21
+    }
22
+
23
+    public void setValue(Integer value) {
24
+        this.value = value;
25
+    }
10 26
 
11 27
     public ArrayUtility(SomeType[] array) {
28
+
12 29
         this.array = array;
13 30
     }
14 31
 
15 32
     public SomeType findOddOccurringValue() {
33
+        for (SomeType T : array){
34
+            if (map.containsKey(T)){
35
+                map.put(T, map.get(T) + 1);
36
+            } else {
37
+                map.put(T, 1);
38
+            }
39
+
40
+        }
41
+
42
+        for (Map.Entry<SomeType, Integer> entry : map.entrySet()){
43
+            if (entry.getValue() % 2 != 0){
44
+                return entry.getKey();
45
+            }
46
+        }
16 47
         return null;
17 48
     }
18 49
 
19
-    public SomeType findEvenOccurringValue() {
50
+    public SomeType findEvenOccurringValue() {for (SomeType T : array){
51
+        if (map.containsKey(T)){
52
+            map.put(T, map.get(T) + 1);
53
+        } else {
54
+            map.put(T, 1);
55
+        }
56
+
57
+    }
58
+
59
+        for (Map.Entry<SomeType, Integer> entry : map.entrySet()){
60
+            if (entry.getValue() % 2 == 0){
61
+                return entry.getKey();
62
+            }
63
+        }
20 64
         return null;
21 65
     }
22 66
 
23 67
     public Integer getNumberOfOccurrences(SomeType valueToEvaluate) {
68
+        int count = 0;
69
+        for (Map.Entry<SomeType, Integer> entry : map.entrySet()){
70
+
71
+            if (entry.getKey() == valueToEvaluate){
72
+                entry.setValue(map.put(valueToEvaluate, map.get(valueToEvaluate) + 1));
73
+                System.out.println(count);
74
+            }
75
+
76
+        }
24 77
         return null;
25 78
     }
26 79
 

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

@@ -4,13 +4,28 @@ 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
+    //ADD_ENUMERATIONS_HERE;
8
+
9
+        ROCK,
10
+        PAPER,
11
+        SCISSOR;
12
+
13
+
14
+
15
+
16
+
17
+    RockPaperScissorHandSign() {
18
+
19
+    }
8 20
 
9 21
     public RockPaperScissorHandSign getWinner() {
22
+
10 23
         return null;
11 24
     }
12 25
 
13 26
     public RockPaperScissorHandSign getLoser() {
14 27
         return null;
15 28
     }
29
+
30
+
16 31
 }