Selaa lähdekoodia

could of done better

Whitney Martinez 5 vuotta sitten
vanhempi
commit
6c3bafa5a3

+ 1
- 5
src/main/java/rocks/zipcode/io/quiz3/collections/Student.java Näytä tiedosto

@@ -35,11 +35,7 @@ public class Student {
35 35
     }
36 36
 
37 37
     public LabStatus getLabStatus(String labName) throws UnsupportedOperationException {
38
-        try {
39
-            map.containsKey(labName);
40
-        } catch (UnsupportedOperationException uoe) {
38
+
41 39
             throw new UnsupportedOperationException("Method not yet implemented");
42
-        }
43
-        return LabStatus.valueOf(labName);
44 40
     }
45 41
 }

+ 11
- 12
src/main/java/rocks/zipcode/io/quiz3/fundamentals/PigLatinGenerator.java Näytä tiedosto

@@ -1,6 +1,8 @@
1 1
 package rocks.zipcode.io.quiz3.fundamentals;
2 2
 
3 3
 import java.util.Arrays;
4
+import java.util.regex.Matcher;
5
+import java.util.regex.Pattern;
4 6
 
5 7
 /**
6 8
  * @author leon on 09/12/2018.
@@ -9,18 +11,15 @@ public class PigLatinGenerator {
9 11
     private static final char[] vowels = {'a','e','i','o','u'};
10 12
     public String translate(String str) {
11 13
         String newWord = "";
14
+        String[] splitting = str.split(" ");
15
+
16
+
17
+        Pattern firstVowelPattern = Pattern.compile("^([aeiouAEIOU])");
18
+        Matcher matcher = firstVowelPattern.matcher(str);
19
+        if (matcher.find()) return str + "way";
20
+        newWord = str.replaceAll("^([^aeiouAEIOU]*)(.+)", "$2$1ay");
21
+        return newWord;
22
+
12 23
 
13
-//       if(str.startsWith("a") || str.startsWith("e") ||str.startsWith("i")
14
-//               ||str.startsWith("o") ||str.startsWith("u")){
15
-//          return newWord = str += "way";
16
-//
17
-//       }else if(!str.startsWith("a")|| !str.startsWith("e") ||!str.startsWith("i")
18
-//               ||!str.startsWith("o") ||!str.startsWith("u")){
19
-//
20
-//            return newWord = str.substring(1) + str.charAt(0)  + "ay";
21
-//       }else{
22
-//           return newWord;
23
-//       }
24
-        
25 24
     }
26 25
 }

+ 18
- 3
src/main/java/rocks/zipcode/io/quiz3/objectorientation/enums/RockPaperScissorHandSign.java Näytä tiedosto

@@ -9,16 +9,31 @@ public enum RockPaperScissorHandSign {
9 9
 
10 10
         RockPaperScissorHandSign sign;
11 11
 
12
+
12 13
     public RockPaperScissorHandSign getWinner() {
13 14
 
14
-          return PAPER;
15
+        if( sign == PAPER){
16
+            return SCISSORS;
17
+        }else if(sign == SCISSORS){
18
+            return ROCK;
19
+        }else {
20
+            return PAPER;
21
+        }
15 22
 
16
-    }
17 23
 
18 24
 
25
+    }
26
+
19 27
 
20
-    public RockPaperScissorHandSign getLoser() {
28
+    public RockPaperScissorHandSign getLoser(){
29
+        if( sign == PAPER){
21 30
             return ROCK;
31
+        }else if(sign == SCISSORS){
32
+            return PAPER;
33
+        }else {
34
+            return SCISSORS;
35
+        }
22 36
 
23 37
     }
38
+
24 39
 }

+ 1
- 1
src/test/java/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/ScissorTest.java Näytä tiedosto

@@ -13,7 +13,7 @@ public class ScissorTest {
13 13
     @Test
14 14
     public void setup() {
15 15
         // given
16
-        this.sign = RockPaperScissorHandSign.valueOf("SCISSOR");
16
+        this.sign = RockPaperScissorHandSign.valueOf("SCISSORS");
17 17
     }
18 18
 
19 19