Przeglądaj źródła

updated changes

Elliott Stansbury 5 lat temu
rodzic
commit
bf81a2103f

+ 7
- 0
pom.xml Wyświetl plik

20
         </plugins>
20
         </plugins>
21
     </build>
21
     </build>
22
     <dependencies>
22
     <dependencies>
23
+        <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
24
+        <dependency>
25
+            <groupId>org.apache.commons</groupId>
26
+            <artifactId>commons-lang3</artifactId>
27
+            <version>3.0</version>
28
+        </dependency>
29
+
23
         <dependency>
30
         <dependency>
24
             <groupId>junit</groupId>
31
             <groupId>junit</groupId>
25
             <artifactId>junit</artifactId>
32
             <artifactId>junit</artifactId>

+ 43
- 4
src/main/java/rocks/zipcode/io/quiz3/arrays/TicTacToe.java Wyświetl plik

1
 package rocks.zipcode.io.quiz3.arrays;
1
 package rocks.zipcode.io.quiz3.arrays;
2
 
2
 
3
+import java.util.ArrayList;
4
+import java.util.Arrays;
5
+
3
 /**
6
 /**
4
  * @author leon on 09/12/2018.
7
  * @author leon on 09/12/2018.
5
  */
8
  */
21
     }
24
     }
22
 
25
 
23
     public String[] getColumn(Integer value) {
26
     public String[] getColumn(Integer value) {
27
+        ArrayList list = new ArrayList();
28
+        for(int i =0; i< board.length; i++){
29
+            list.add(board[i][value]);
24
 
30
 
25
-        for(int i = 0; i< row.length;i++) {
26
-            column[i] = board[0][value];
27
         }
31
         }
32
+        Object[] columnObj = list.toArray();
33
+
34
+        column = Arrays.copyOf(columnObj,columnObj.length, String[].class);
28
         return column;
35
         return column;
29
     }
36
     }
30
 
37
 
31
     public Boolean isRowHomogenous(Integer rowIndex) {
38
     public Boolean isRowHomogenous(Integer rowIndex) {
32
-        return null;
39
+
40
+        String[] newRow = getRow(rowIndex);
41
+
42
+        String check = newRow[0];
43
+        for(int i = 0; i< newRow.length; i++){
44
+                if(check != newRow[i]){
45
+                    return false;
46
+                }
47
+        }
48
+
49
+
50
+
51
+        return true;
33
     }
52
     }
34
 
53
 
35
     public Boolean isColumnHomogeneous(Integer columnIndex) {
54
     public Boolean isColumnHomogeneous(Integer columnIndex) {
36
-        return null;
55
+
56
+        String[] newColumn = getColumn(columnIndex);
57
+
58
+        String check = newColumn[0];
59
+
60
+        for(int i = 0; i < newColumn.length; i++){
61
+            if(check != newColumn[i]){
62
+                return false;
63
+            }
64
+        }
65
+
66
+        return true;
37
     }
67
     }
38
 
68
 
39
     public String getWinner() {
69
     public String getWinner() {
70
+
71
+        for(int i = 0; i < board.length; i++) {
72
+            if (isColumnHomogeneous(i)){
73
+                return column[i];
74
+            } else if(isRowHomogenous(i)){
75
+                return row[i];
76
+            }
77
+        }
78
+
40
         return null;
79
         return null;
41
     }
80
     }
42
 }
81
 }

+ 49
- 1
src/main/java/rocks/zipcode/io/quiz3/arrays/WaveGenerator.java Wyświetl plik

1
 package rocks.zipcode.io.quiz3.arrays;
1
 package rocks.zipcode.io.quiz3.arrays;
2
 
2
 
3
+import java.util.ArrayList;
4
+import java.util.Arrays;
5
+
3
 /**
6
 /**
4
  * @author leon on 09/12/2018.
7
  * @author leon on 09/12/2018.
5
  */
8
  */
6
 public class WaveGenerator {
9
 public class WaveGenerator {
7
     public static String[] wave(String str) {
10
     public static String[] wave(String str) {
8
-        return null;
11
+
12
+        String combined = "";
13
+
14
+        String[] letters = new String[str.length()];
15
+        String[] array = new String[str.length()];
16
+
17
+        for(int i = 0; i < array.length; i++){
18
+            array[i] = str.toLowerCase();
19
+            letters = array[i].split("");
20
+        }
21
+
22
+        StringBuilder builder = new StringBuilder();
23
+        for(int i = 0; i < array.length; i++){
24
+            letters[i] = letters[i].toUpperCase();
25
+
26
+//            System.out.println(Arrays.toString(letters));
27
+//            combined.join(",",letters);
28
+
29
+            combined = Arrays.toString(letters);
30
+
31
+
32
+
33
+            array[i] = combined;
34
+//            System.out.println(combined);
35
+//            System.out.println(combined);
36
+            for(int j = 1; j < array.length; j++) {
37
+                letters[i] = letters[j - 1].toLowerCase();
38
+
39
+            }
40
+//            System.out.println(Arrays.toString(letters) + "afterLowerCase");
41
+            System.out.println(array[i].join(",",combined));
42
+        }
43
+
44
+
45
+
46
+
47
+
48
+
49
+//        System.out.println(Arrays.toString(array));
50
+
51
+
52
+
53
+        //at each index of i.. I want to uppercase 1 letter in array.
54
+
55
+
56
+        return array;
9
     }
57
     }
10
 }
58
 }

+ 23
- 4
src/main/java/rocks/zipcode/io/quiz3/collections/Lab.java Wyświetl plik

1
 package rocks.zipcode.io.quiz3.collections;
1
 package rocks.zipcode.io.quiz3.collections;
2
 
2
 
3
+import rocks.zipcode.io.quiz3.objectorientation.enums.LabStatus;
4
+
3
 /**
5
 /**
4
  * @author leon on 10/12/2018.
6
  * @author leon on 10/12/2018.
5
  */
7
  */
6
-public class Lab {
8
+public class Lab  {
9
+
10
+    String labName;
11
+    String labStatus;
12
+    String name;
13
+
14
+    Student student = new Student();
15
+
16
+    public String getLabName() {
17
+        return labName;
18
+    }
19
+
20
+    public void setLabName(String labName) {
21
+        this.labName = labName;
22
+    }
23
+
7
     public Lab() {
24
     public Lab() {
8
-        this(null);
25
+
26
+        this("");
9
     }
27
     }
10
 
28
 
11
     public Lab(String labName) {
29
     public Lab(String labName) {
12
     }
30
     }
13
 
31
 
14
     public String getLabStatus() {
32
     public String getLabStatus() {
15
-        return null;
33
+        return labStatus;
16
     }
34
     }
17
 
35
 
18
     public void setLabStatus(String labStatus) {
36
     public void setLabStatus(String labStatus) {
37
+        this.labStatus = labStatus;
19
     }
38
     }
20
 
39
 
21
     public String getName() {
40
     public String getName() {
22
-        return null;
41
+        return labName;
23
     }
42
     }
24
 }
43
 }

+ 3
- 0
src/main/java/rocks/zipcode/io/quiz3/collections/Student.java Wyświetl plik

13
     }
13
     }
14
 
14
 
15
     public Student(Map<Lab, LabStatus> map) {
15
     public Student(Map<Lab, LabStatus> map) {
16
+
16
     }
17
     }
17
 
18
 
18
     public void setLabStatus(Lab lab, LabStatus labStatus) {
19
     public void setLabStatus(Lab lab, LabStatus labStatus) {
20
 
21
 
21
 
22
 
22
     public void forkLab(Lab lab) {
23
     public void forkLab(Lab lab) {
24
+
23
     }
25
     }
24
 
26
 
25
     public LabStatus getLabStatus(String labName) {
27
     public LabStatus getLabStatus(String labName) {
28
+
26
         throw new UnsupportedOperationException("Method not yet implemented");
29
         throw new UnsupportedOperationException("Method not yet implemented");
27
     }
30
     }
28
 }
31
 }

+ 31
- 1
src/main/java/rocks/zipcode/io/quiz3/fundamentals/PigLatinGenerator.java Wyświetl plik

1
 package rocks.zipcode.io.quiz3.fundamentals;
1
 package rocks.zipcode.io.quiz3.fundamentals;
2
 
2
 
3
+import java.util.ArrayList;
4
+import java.util.Arrays;
5
+import java.util.List;
6
+
3
 /**
7
 /**
4
  * @author leon on 09/12/2018.
8
  * @author leon on 09/12/2018.
5
  */
9
  */
6
 public class PigLatinGenerator {
10
 public class PigLatinGenerator {
7
     public String translate(String str) {
11
     public String translate(String str) {
8
-        return null;
12
+
13
+            String[] words = str.split(" ");
14
+            for(int i = 0; i < words.length; i++){
15
+                if(VowelUtils.startsWithVowel(words[i])){
16
+                    words[i] = words[i] + "way";
17
+                }else if(!VowelUtils.startsWithVowel(words[i])){
18
+                    Integer firstVowel = VowelUtils.getIndexOfFirstVowel(words[i]);
19
+                    System.out.println(firstVowel);
20
+                    Character firstLetter = words[i].charAt(0);
21
+                    String sub = words[i].substring(0,firstVowel);
22
+                    System.out.println();
23
+                    if(firstVowel != null) {
24
+                        words[i] = words[i].substring(firstVowel);
25
+                        words[i] = words[i] + sub + "ay";
26
+                    }else{
27
+                        words[i] = words[i].substring(1);
28
+                        words[i] = words[i] + firstLetter + "ay";
29
+                    }
30
+                }
31
+            }
32
+
33
+            String newStr = String.join(",", words);
34
+            String newNewStr = newStr.replaceAll(",", " ");
35
+
36
+
37
+
38
+            return newNewStr;
9
     }
39
     }
10
 }
40
 }

+ 28
- 2
src/main/java/rocks/zipcode/io/quiz3/fundamentals/StringUtils.java Wyświetl plik

4
  * @author leon on 09/12/2018.
4
  * @author leon on 09/12/2018.
5
  */
5
  */
6
 public class StringUtils {
6
 public class StringUtils {
7
+
8
+
7
     public static String capitalizeNthCharacter(String str, Integer indexToCapitalize) {
9
     public static String capitalizeNthCharacter(String str, Integer indexToCapitalize) {
8
-        return null;
10
+
11
+
12
+
13
+        char[] letters = str.toCharArray();
14
+
15
+        for(int i = 0; i < letters.length; i++){
16
+            if(i == indexToCapitalize){
17
+                letters[i] = Character.toUpperCase(letters[i]);
18
+            }
19
+        }
20
+        String newStr = new String(letters);
21
+
22
+
23
+        return newStr;
9
     }
24
     }
10
 
25
 
11
     public static Boolean isCharacterAtIndex(String baseString, Character characterToCheckFor, Integer indexOfString) {
26
     public static Boolean isCharacterAtIndex(String baseString, Character characterToCheckFor, Integer indexOfString) {
12
-        return null;
27
+
28
+        String newStr = baseString.toLowerCase();
29
+        char[] letters = newStr.toCharArray();
30
+        for(int i = 0; i < letters.length; i++){
31
+            if(i == indexOfString && letters[i] == characterToCheckFor){
32
+                return true;
33
+            }
34
+        }
35
+
36
+        return false;
13
     }
37
     }
38
+
39
+
14
 }
40
 }

+ 41
- 3
src/main/java/rocks/zipcode/io/quiz3/fundamentals/VowelUtils.java Wyświetl plik

1
 package rocks.zipcode.io.quiz3.fundamentals;
1
 package rocks.zipcode.io.quiz3.fundamentals;
2
 
2
 
3
+import java.util.List;
4
+
3
 /**
5
 /**
4
  * @author leon on 09/12/2018.
6
  * @author leon on 09/12/2018.
5
  */
7
  */
6
 public class VowelUtils {
8
 public class VowelUtils {
7
     public static Boolean hasVowels(String word) {
9
     public static Boolean hasVowels(String word) {
8
-        return null;
10
+
11
+        String vowels = "aeiou";
12
+
13
+        for(int i = 0; i < word.length(); i++){
14
+            if(vowels.contains(String.valueOf(word.charAt(i)))){
15
+                return true;
16
+            }
17
+        }
18
+        return false;
9
     }
19
     }
10
 
20
 
11
     public static Integer getIndexOfFirstVowel(String word) {
21
     public static Integer getIndexOfFirstVowel(String word) {
22
+
23
+       String vowels = "aeiouAEIOU";
24
+
25
+       for(int i = 0; i < word.length(); i++){
26
+           if(vowels.contains(String.valueOf(word.charAt(i)))){
27
+               return i;
28
+           }
29
+       }
30
+
31
+
12
         return null;
32
         return null;
13
     }
33
     }
14
 
34
 
15
 
35
 
16
     public static Boolean startsWithVowel(String word) {
36
     public static Boolean startsWithVowel(String word) {
17
-        return null;
37
+
38
+        if(!isVowel(word.charAt(0))) {
39
+            return false;
40
+        }
41
+        return true;
18
     }
42
     }
19
 
43
 
20
     public static Boolean isVowel(Character character) {
44
     public static Boolean isVowel(Character character) {
21
-        return null;
45
+
46
+        if(character == 'a'
47
+        || character == 'e'
48
+        || character == 'i'
49
+        || character == 'o'
50
+        || character == 'u'
51
+        || character == 'A'
52
+        || character == 'E'
53
+        || character == 'I'
54
+        || character == 'O'
55
+        || character == 'U'){
56
+            return true;
57
+        }
58
+
59
+        return false;
22
     }
60
     }
23
 }
61
 }

+ 27
- 1
src/main/java/rocks/zipcode/io/quiz3/generics/ArrayUtility.java Wyświetl plik

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

+ 3
- 1
src/main/java/rocks/zipcode/io/quiz3/objectorientation/enums/LabStatus.java Wyświetl plik

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

+ 1
- 1
src/main/java/rocks/zipcode/io/quiz3/objectorientation/enums/RockPaperScissorHandSign.java Wyświetl plik

4
  * @author leon on 09/12/2018.
4
  * @author leon on 09/12/2018.
5
  */
5
  */
6
 public enum RockPaperScissorHandSign {
6
 public enum RockPaperScissorHandSign {
7
-    ADD_ENUMERATIONS_HERE;
7
+    ROCK,PAPER,SCISSORS;
8
 
8
 
9
     public RockPaperScissorHandSign getWinner() {
9
     public RockPaperScissorHandSign getWinner() {
10
         return null;
10
         return null;