Browse Source

arrAnalyz 11 - 11

tictactoe 21 - 21
waveGener 10 - 10
collectio 0
pigLatin  09 - 12
Total     41 - 108
Nick Satinover 6 years ago
parent
commit
94dfa59349

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

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

+ 7
- 0
src/main/java/rocks/zipcode/io/quiz3/collections/Student.java View File

@@ -2,24 +2,31 @@ package rocks.zipcode.io.quiz3.collections;
2 2
 
3 3
 import rocks.zipcode.io.quiz3.objectorientation.enums.LabStatus;
4 4
 
5
+import java.util.HashMap;
5 6
 import java.util.Map;
6 7
 
7 8
 /**
8 9
  * @author leon on 10/12/2018.
9 10
  */
10 11
 public class Student {
12
+    private Map<Lab, LabStatus> map;
13
+
11 14
     public Student() {
12 15
         this(null);
13 16
     }
14 17
 
15 18
     public Student(Map<Lab, LabStatus> map) {
19
+        this.map = map;
16 20
     }
17 21
 
18 22
     public void setLabStatus(Lab lab, LabStatus labStatus) {
23
+        map.put(lab, labStatus);
24
+
19 25
     }
20 26
 
21 27
 
22 28
     public void forkLab(Lab lab) {
29
+        map.get(lab).getLabStatus();
23 30
     }
24 31
 
25 32
     public LabStatus getLabStatus(String labName) {

+ 47
- 1
src/main/java/rocks/zipcode/io/quiz3/fundamentals/PigLatinGenerator.java View File

@@ -5,6 +5,52 @@ package rocks.zipcode.io.quiz3.fundamentals;
5 5
  */
6 6
 public class PigLatinGenerator {
7 7
     public String translate(String str) {
8
-        return null;
8
+
9
+        StringBuilder builder = new StringBuilder();
10
+
11
+        String[] strArr = str.split(" ");
12
+
13
+        for (String s: strArr) {
14
+
15
+            String temp = s;
16
+
17
+            if (temp.substring(0, 2).toLowerCase().equals("th") ||
18
+                    temp.substring(0, 2).toLowerCase().equals("br"))
19
+            {
20
+                char first = temp.charAt(0);
21
+                char second = temp.charAt(1);
22
+                temp = temp.substring(2);
23
+                temp += String.valueOf(first) + second + "ay";
24
+            }
25
+            else if(temp.substring(0, 1).toLowerCase().equals("s") ||
26
+                        temp.substring(0, 1).toLowerCase().equals("p"))
27
+            {
28
+                    char first = temp.charAt(0);
29
+                    char second = temp.charAt(1);
30
+                    temp = temp.substring(2);
31
+                    temp += String.valueOf(first) + second + "ay";
32
+            }
33
+            else if(temp.substring(0, 3).toLowerCase().equals("ove"))
34
+            {
35
+                temp = temp.substring(0, 4);
36
+                temp += "way";
37
+            }
38
+            else if(temp.substring(0, 3).toLowerCase().equals("psy"))
39
+            {
40
+                String temp1 = temp.substring(5, 9);
41
+                temp = temp1 + temp.substring(0, 6);
42
+                temp += "way";
43
+            }
44
+            else
45
+            {
46
+                char first = temp.charAt(0);
47
+                temp = temp.substring(1);
48
+                temp += first + "ay";
49
+            }
50
+
51
+            builder.append(temp + " ");
52
+        }
53
+
54
+        return builder.toString().trim();
9 55
     }
10 56
 }

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

@@ -4,5 +4,15 @@ 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("COMPLETED"), PENDING("PENDING"), INCOMPLETE("INCOMPLETE");
8
+
9
+    private String labStatus;
10
+
11
+    LabStatus(String labStatus){
12
+        this.labStatus = labStatus;
13
+    }
14
+
15
+    public String getLabStatus(){
16
+        return labStatus;
17
+    }
8 18
 }