Leon vor 6 Jahren
Commit
af632ea460
64 geänderte Dateien mit 2358 neuen und 0 gelöschten Zeilen
  1. 13
    0
      .idea/compiler.xml
  2. 14
    0
      .idea/misc.xml
  3. 124
    0
      .idea/uiDesigner.xml
  4. 1079
    0
      .idea/workspace.xml
  5. 45
    0
      README.md
  6. 32
    0
      pom.xml
  7. 2
    0
      quiz3.iml
  8. 22
    0
      src/main/java/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.java
  9. 32
    0
      src/main/java/rocks/zipcode/io/quiz3/arrays/TicTacToe.java
  10. 24
    0
      src/main/java/rocks/zipcode/io/quiz3/arrays/WaveGenerator.java
  11. 20
    0
      src/main/java/rocks/zipcode/io/quiz3/collections/Person.java
  12. 13
    0
      src/main/java/rocks/zipcode/io/quiz3/collections/Shoe.java
  13. 26
    0
      src/main/java/rocks/zipcode/io/quiz3/collections/ShoeFitter.java
  14. 8
    0
      src/main/java/rocks/zipcode/io/quiz3/collections/ShoeSize.java
  15. 38
    0
      src/main/java/rocks/zipcode/io/quiz3/fundamentals/PigLatinGenerator.java
  16. 14
    0
      src/main/java/rocks/zipcode/io/quiz3/fundamentals/StringUtils.java
  17. 37
    0
      src/main/java/rocks/zipcode/io/quiz3/fundamentals/VowelUtils.java
  18. 30
    0
      src/main/java/rocks/zipcode/io/quiz3/generics/ArrayUtility.java
  19. 16
    0
      src/main/java/rocks/zipcode/io/quiz3/objectorientation/enums/RockPaperScissorHandSign.java
  20. 16
    0
      src/test/java/rocks/zipcode/io/quiz3/TestUtils.java
  21. 43
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSentence.java
  22. 55
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSingleWordStartingWithConsonant.java
  23. 28
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSingleWordStartingWithVowel.java
  24. 7
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/stringutils/IsCharacterAtIndex.java
  25. 7
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/vowelutils/GetIndexOfFirstVowel.java
  26. 7
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/vowelutils/HasVowels.java
  27. 7
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/vowelutils/IsVowel.java
  28. 7
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/vowelutils/StartsWithVowel.java
  29. 55
    0
      src/test/java/rocks/zipcode/io/quiz3/fundamentals/wavegenerator/WaveTest.java
  30. 87
    0
      src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerFilterTest.java
  31. 53
    0
      src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerFindEvenOccurringValue.java
  32. 53
    0
      src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerFindOddOccurringValue.java
  33. 56
    0
      src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerGetNumberOfOccurrences.java
  34. 52
    0
      src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFilterTest.java
  35. 47
    0
      src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFindEvenOccurringValueTest.java
  36. 46
    0
      src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFindOddOccurringValueTest.java
  37. 49
    0
      src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringGetNumberOfOccurrencesTest.java
  38. 31
    0
      src/test/java/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/PaperTest.java
  39. 32
    0
      src/test/java/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/RockTest.java
  40. 31
    0
      src/test/java/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/ScissorTest.java
  41. BIN
      target/classes/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.class
  42. BIN
      target/classes/rocks/zipcode/io/quiz3/arrays/TicTacToe.class
  43. BIN
      target/classes/rocks/zipcode/io/quiz3/arrays/WaveGenerator.class
  44. BIN
      target/classes/rocks/zipcode/io/quiz3/collections/Person.class
  45. BIN
      target/classes/rocks/zipcode/io/quiz3/collections/Shoe.class
  46. BIN
      target/classes/rocks/zipcode/io/quiz3/collections/ShoeFitter.class
  47. BIN
      target/classes/rocks/zipcode/io/quiz3/collections/ShoeSize.class
  48. BIN
      target/classes/rocks/zipcode/io/quiz3/fundamentals/PigLatinGenerator.class
  49. BIN
      target/classes/rocks/zipcode/io/quiz3/fundamentals/StringUtils.class
  50. BIN
      target/classes/rocks/zipcode/io/quiz3/fundamentals/VowelUtils.class
  51. BIN
      target/classes/rocks/zipcode/io/quiz3/generics/ArrayUtility.class
  52. BIN
      target/classes/rocks/zipcode/io/quiz3/objectorientation/enums/RockPaperScissorHandSign.class
  53. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSentence.class
  54. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSingleWordStartingWithConsonant.class
  55. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSingleWordStartingWithVowel.class
  56. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/stringutils/IsCharacterAtIndex.class
  57. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/vowelutils/GetIndexOfFirstVowel.class
  58. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/vowelutils/HasVowels.class
  59. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/vowelutils/IsVowel.class
  60. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/vowelutils/StartsWithVowel.class
  61. BIN
      target/test-classes/rocks/zipcode/io/quiz3/fundamentals/wavegenerator/WaveTest.class
  62. BIN
      target/test-classes/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/PaperTest.class
  63. BIN
      target/test-classes/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/RockTest.class
  64. BIN
      target/test-classes/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/ScissorTest.class

+ 13
- 0
.idea/compiler.xml Datei anzeigen

@@ -0,0 +1,13 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="CompilerConfiguration">
4
+    <annotationProcessing>
5
+      <profile name="Maven default annotation processors profile" enabled="true">
6
+        <sourceOutputDir name="target/generated-sources/annotations" />
7
+        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
8
+        <outputRelativeToContentRoot value="true" />
9
+        <module name="quiz3" />
10
+      </profile>
11
+    </annotationProcessing>
12
+  </component>
13
+</project>

+ 14
- 0
.idea/misc.xml Datei anzeigen

@@ -0,0 +1,14 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
4
+  <component name="MavenProjectsManager">
5
+    <option name="originalFiles">
6
+      <list>
7
+        <option value="$PROJECT_DIR$/pom.xml" />
8
+      </list>
9
+    </option>
10
+  </component>
11
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
12
+    <output url="file://$PROJECT_DIR$/out" />
13
+  </component>
14
+</project>

+ 124
- 0
.idea/uiDesigner.xml Datei anzeigen

@@ -0,0 +1,124 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="Palette2">
4
+    <group name="Swing">
5
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
6
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
7
+      </item>
8
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
9
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
10
+      </item>
11
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
12
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
13
+      </item>
14
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
15
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
16
+      </item>
17
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
18
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
19
+        <initial-values>
20
+          <property name="text" value="Button" />
21
+        </initial-values>
22
+      </item>
23
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
24
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
25
+        <initial-values>
26
+          <property name="text" value="RadioButton" />
27
+        </initial-values>
28
+      </item>
29
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
30
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
31
+        <initial-values>
32
+          <property name="text" value="CheckBox" />
33
+        </initial-values>
34
+      </item>
35
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
36
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
37
+        <initial-values>
38
+          <property name="text" value="Label" />
39
+        </initial-values>
40
+      </item>
41
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
42
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
43
+          <preferred-size width="150" height="-1" />
44
+        </default-constraints>
45
+      </item>
46
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
47
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
48
+          <preferred-size width="150" height="-1" />
49
+        </default-constraints>
50
+      </item>
51
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
52
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
53
+          <preferred-size width="150" height="-1" />
54
+        </default-constraints>
55
+      </item>
56
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
57
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
58
+          <preferred-size width="150" height="50" />
59
+        </default-constraints>
60
+      </item>
61
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
62
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
63
+          <preferred-size width="150" height="50" />
64
+        </default-constraints>
65
+      </item>
66
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
67
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
68
+          <preferred-size width="150" height="50" />
69
+        </default-constraints>
70
+      </item>
71
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
72
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
73
+      </item>
74
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
75
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
76
+          <preferred-size width="150" height="50" />
77
+        </default-constraints>
78
+      </item>
79
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
80
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
81
+          <preferred-size width="150" height="50" />
82
+        </default-constraints>
83
+      </item>
84
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
85
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
86
+          <preferred-size width="150" height="50" />
87
+        </default-constraints>
88
+      </item>
89
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
90
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
91
+          <preferred-size width="200" height="200" />
92
+        </default-constraints>
93
+      </item>
94
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
95
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
96
+          <preferred-size width="200" height="200" />
97
+        </default-constraints>
98
+      </item>
99
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
100
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
101
+      </item>
102
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
103
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
104
+      </item>
105
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
106
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
107
+      </item>
108
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
109
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
110
+      </item>
111
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
112
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
113
+          <preferred-size width="-1" height="20" />
114
+        </default-constraints>
115
+      </item>
116
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
117
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
118
+      </item>
119
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
120
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
121
+      </item>
122
+    </group>
123
+  </component>
124
+</project>

+ 1079
- 0
.idea/workspace.xml
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 45
- 0
README.md Datei anzeigen

@@ -0,0 +1,45 @@
1
+# Pig Latin
2
+* Pig Latin is an English language game where the goal is to hide the meaning of a word from people not aware of the rules.
3
+* The rules themselves are rather easy:
4
+* 1) The word starts with a vowel(a,e,i,o,u) -> return the original string plus "way".
5
+* 2) The word starts with a consonant -> move consonants from the beginning of the word to the end of the word until the first vowel, then return it plus "ay".
6
+* 3) The result must be lowercase, regardless of the case of the input. If the input string has any non-alpha characters, the function must return None, null, Nothing (depending on the language).
7
+* 4) The function must also handle simple random strings and not just English words.
8
+* 5) The input string has no vowels -> return the original string plus "ay".
9
+* For example, the word "spaghetti" becomes "aghettispay" because the first two letters ("sp") are consonants, so they are moved to the end of the string and "ay" is appended.
10
+
11
+
12
+# Square Array Checker
13
+* Given two arrays `a` and `b` write a method `compare(a, b)` that returns true if the two arrays have the "same" elements, with the same multiplicities. "Same" means, here, that the elements in `b` are the elements in `a` squared, regardless of the order.
14
+
15
+
16
+#### Example 1 - Valid Array 
17
+```
18
+a = [121, 144, 19, 161, 19, 144, 19, 11]  
19
+b = [121, 14641, 20736, 361, 25921, 361, 20736, 361]
20
+```
21
+* `compare(a, b)` returns true because in `b`
22
+	* 121 is the square of 11,
23
+	* 14641 is the square of 121,
24
+	* 20736 the square of 144,
25
+	* 361 the square of 19,
26
+	* 25921 the square of 161,
27
+and so on.
28
+
29
+
30
+
31
+#### Example 2 - Invalid Array 
32
+```
33
+a = [121, 144, 19, 161, 19, 144, 19, 11]  
34
+b = [132, 14641, 20736, 361, 25921, 361, 20736, 361]
35
+```
36
+`compare(a,b)` returns `false` because in `b` 132 is not the square of any number of `a`.
37
+
38
+
39
+#### Example 3 - Invalid Array 
40
+```
41
+a = [121, 144, 19, 161, 19, 144, 19, 11]  
42
+b = [121, 14641, 20736, 36100, 25921, 361, 20736, 361]
43
+```
44
+
45
+`comp(a,b)` returns `false` because in `b` 36100 is not the square of any number of `a`.

+ 32
- 0
pom.xml Datei anzeigen

@@ -0,0 +1,32 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <modelVersion>4.0.0</modelVersion>
6
+
7
+    <groupId>rocks.zipcode.io</groupId>
8
+    <artifactId>quiz3</artifactId>
9
+    <version>1.0-SNAPSHOT</version>
10
+    <build>
11
+        <plugins>
12
+            <plugin>
13
+                <groupId>org.apache.maven.plugins</groupId>
14
+                <artifactId>maven-compiler-plugin</artifactId>
15
+                <configuration>
16
+                    <source>8</source>
17
+                    <target>8</target>
18
+                </configuration>
19
+            </plugin>
20
+        </plugins>
21
+    </build>
22
+    <dependencies>
23
+        <dependency>
24
+            <groupId>junit</groupId>
25
+            <artifactId>junit</artifactId>
26
+            <version>4.12</version>
27
+            <scope>test</scope>
28
+        </dependency>
29
+    </dependencies>
30
+
31
+
32
+</project>

+ 2
- 0
quiz3.iml Datei anzeigen

@@ -0,0 +1,2 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module type="JAVA_MODULE" version="4" />

+ 22
- 0
src/main/java/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.java Datei anzeigen

@@ -0,0 +1,22 @@
1
+package rocks.zipcode.io.quiz3.arrays;
2
+
3
+import java.util.Arrays;
4
+
5
+/**
6
+ * @author leon on 09/12/2018.
7
+ */
8
+public class SquareArrayAnalyzer {
9
+    public static Boolean compare(Integer[] input, Integer[] squaredValues) {
10
+        try {
11
+            for (int i = 0; i < input.length; i++) {
12
+                Integer currentElement = input[i];
13
+                input[i] = currentElement * currentElement;
14
+            }
15
+            Arrays.sort(input);
16
+            Arrays.sort(squaredValues);
17
+            return Arrays.toString(input).equals(Arrays.toString(squaredValues));
18
+        } catch(NullPointerException npe) {
19
+            return false;
20
+        }
21
+    }
22
+}

+ 32
- 0
src/main/java/rocks/zipcode/io/quiz3/arrays/TicTacToe.java Datei anzeigen

@@ -0,0 +1,32 @@
1
+package rocks.zipcode.io.quiz3.arrays;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class TicTacToe {
7
+    private final String[][] board;
8
+
9
+    public TicTacToe(String[][] board) {
10
+        this.board = board;
11
+    }
12
+
13
+    public String[] getRow(Integer value) {
14
+        return null;
15
+    }
16
+
17
+    public String[] getColumn(Integer value) {
18
+        return null;
19
+    }
20
+
21
+    public Boolean isRowHomogenous(Integer value) {
22
+        return null;
23
+    }
24
+
25
+    public Boolean isColumnHomogenous(Integer value) {
26
+        return null;
27
+    }
28
+
29
+    public String getWinner() {
30
+        return null;
31
+    }
32
+}

+ 24
- 0
src/main/java/rocks/zipcode/io/quiz3/arrays/WaveGenerator.java Datei anzeigen

@@ -0,0 +1,24 @@
1
+package rocks.zipcode.io.quiz3.arrays;
2
+
3
+import rocks.zipcode.io.quiz3.fundamentals.StringUtils;
4
+
5
+import java.util.ArrayList;
6
+import java.util.List;
7
+
8
+/**
9
+ * @author leon on 09/12/2018.
10
+ */
11
+public class WaveGenerator {
12
+    public static String[] wave(String str) {
13
+        List<String> list = new ArrayList<>();
14
+        for (int i = 0; i < str.length(); i++) {
15
+            String currentCharacter = String.valueOf(str.charAt(i));
16
+            String capitalizedFirstCharacter = currentCharacter.toUpperCase();
17
+            Boolean hasNoEffect = currentCharacter.equals(capitalizedFirstCharacter);
18
+            if(!hasNoEffect) {
19
+                list.add(StringUtils.capitalizeNthCharacter(str, i));
20
+            }
21
+        }
22
+        return list.toArray(new String[list.size()]);
23
+    }
24
+}

+ 20
- 0
src/main/java/rocks/zipcode/io/quiz3/collections/Person.java Datei anzeigen

@@ -0,0 +1,20 @@
1
+package rocks.zipcode.io.quiz3.collections;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class Person {
7
+    public void wearShoe(Shoe clothing) {
8
+    }
9
+
10
+    public void removeShoe(Shoe clothing) {
11
+    }
12
+
13
+    public Double getShoeSizeInInches() {
14
+        return null;
15
+    }
16
+
17
+    public Boolean isWearing(Shoe clothing) {
18
+        return null;
19
+    }
20
+}

+ 13
- 0
src/main/java/rocks/zipcode/io/quiz3/collections/Shoe.java Datei anzeigen

@@ -0,0 +1,13 @@
1
+package rocks.zipcode.io.quiz3.collections;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class Shoe {
7
+    public Shoe(ShoeSize size) {
8
+    }
9
+
10
+    public ShoeSize getSize() {
11
+        return null;
12
+    }
13
+}

+ 26
- 0
src/main/java/rocks/zipcode/io/quiz3/collections/ShoeFitter.java Datei anzeigen

@@ -0,0 +1,26 @@
1
+package rocks.zipcode.io.quiz3.collections;
2
+
3
+import java.util.Map;
4
+
5
+/**
6
+ * @author leon on 09/12/2018.
7
+ */
8
+public class ShoeFitter {
9
+    public ShoeFitter(Map<Person, ShoeSize> shoeSizeMap) {
10
+
11
+    }
12
+
13
+    public ShoeFitter() {
14
+    }
15
+
16
+    public Map<Person, ShoeSize> getShoeSizeMap() {
17
+        return null;
18
+    }
19
+
20
+    public Boolean containsMappingOf(Person person) {
21
+        return null;
22
+    }
23
+
24
+    public void fitShoes() {
25
+    }
26
+}

+ 8
- 0
src/main/java/rocks/zipcode/io/quiz3/collections/ShoeSize.java Datei anzeigen

@@ -0,0 +1,8 @@
1
+package rocks.zipcode.io.quiz3.collections;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public enum ShoeSize {
7
+    ADD_ENUMERATIONS_HERE;
8
+}

+ 38
- 0
src/main/java/rocks/zipcode/io/quiz3/fundamentals/PigLatinGenerator.java Datei anzeigen

@@ -0,0 +1,38 @@
1
+package rocks.zipcode.io.quiz3.fundamentals;
2
+
3
+import static rocks.zipcode.io.quiz3.fundamentals.VowelUtils.getIndexOfFirstVowel;
4
+import static rocks.zipcode.io.quiz3.fundamentals.VowelUtils.hasVowels;
5
+import static rocks.zipcode.io.quiz3.fundamentals.VowelUtils.startsWithVowel;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class PigLatinGenerator {
11
+    public String translate(String str) {
12
+        StringBuilder sb = new StringBuilder();
13
+        for (String word : str.split(" ")) {
14
+            sb.append(transform1(word));
15
+            sb.append(transform2(word));
16
+            sb.append(" ");
17
+        }
18
+        return sb.toString().replaceAll(" $", "");
19
+    }
20
+
21
+    private String transform2(String word) {
22
+        if (word == null || startsWithVowel(word)) {
23
+            return "";
24
+        }
25
+        Integer firstIndexOfVowel = hasVowels(word) ? getIndexOfFirstVowel(word) : word.length();
26
+        String suffix = word.substring(0, firstIndexOfVowel);
27
+        String prefix = word.substring(firstIndexOfVowel, word.length());
28
+        return prefix + suffix + "ay";
29
+    }
30
+
31
+    private String transform1(String word) {
32
+        if (startsWithVowel(word)) {
33
+            return word.concat("way");
34
+        }
35
+        return "";
36
+    }
37
+
38
+}

+ 14
- 0
src/main/java/rocks/zipcode/io/quiz3/fundamentals/StringUtils.java Datei anzeigen

@@ -0,0 +1,14 @@
1
+package rocks.zipcode.io.quiz3.fundamentals;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class StringUtils {
7
+    public static String capitalizeNthCharacter(String baseString, Integer indexToCapitalize) {
8
+        throw new UnsupportedOperationException("Method not yet implemented");
9
+    }
10
+
11
+    public static Boolean isCharacterAtIndex(String baseString, char c) {
12
+        return null;
13
+    }
14
+}

+ 37
- 0
src/main/java/rocks/zipcode/io/quiz3/fundamentals/VowelUtils.java Datei anzeigen

@@ -0,0 +1,37 @@
1
+package rocks.zipcode.io.quiz3.fundamentals;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class VowelUtils {
7
+    private static final String[] vowels = "aeiou".split("");
8
+
9
+    public static boolean hasVowels(String word) {
10
+        return getIndexOfFirstVowel(word) != null;
11
+    }
12
+
13
+    public static Integer getIndexOfFirstVowel(String word) {
14
+        String[] letters = word.split("");
15
+        for (int i = 0; i < letters.length; i++) {
16
+            Character letter = letters[i].charAt(0);
17
+            if (isVowel(letter)) {
18
+                return i;
19
+            }
20
+        }
21
+        return null;
22
+    }
23
+
24
+
25
+    public static Boolean startsWithVowel(String word) {
26
+        return isVowel(word.charAt(0));
27
+    }
28
+
29
+    public static Boolean isVowel(Character character) {
30
+        for (String vowel : vowels) {
31
+            if (character.toString().equalsIgnoreCase(vowel)) {
32
+                return true;
33
+            }
34
+        }
35
+        return false;
36
+    }
37
+}

+ 30
- 0
src/main/java/rocks/zipcode/io/quiz3/generics/ArrayUtility.java Datei anzeigen

@@ -0,0 +1,30 @@
1
+package rocks.zipcode.io.quiz3.generics;
2
+
3
+import java.util.function.Function;
4
+
5
+/**
6
+ * @author leon on 09/12/2018.
7
+ */
8
+public class ArrayUtility<SomeType> {
9
+    private final SomeType[] array;
10
+
11
+    public ArrayUtility(SomeType[] array) {
12
+        this.array = array;
13
+    }
14
+
15
+    public SomeType findOddOccurringValue() {
16
+        return null;
17
+    }
18
+
19
+    public SomeType findEvenOccurringValue() {
20
+        return null;
21
+    }
22
+
23
+    public Integer getNumberOfOccurrences(SomeType valueToEvaluate) {
24
+        return null;
25
+    }
26
+
27
+    public SomeType[] filter(Function<SomeType, Boolean> predicate) {
28
+        return null;
29
+    }
30
+}

+ 16
- 0
src/main/java/rocks/zipcode/io/quiz3/objectorientation/enums/RockPaperScissorHandSign.java Datei anzeigen

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

+ 16
- 0
src/test/java/rocks/zipcode/io/quiz3/TestUtils.java Datei anzeigen

@@ -0,0 +1,16 @@
1
+package rocks.zipcode.io.quiz3;
2
+
3
+import org.junit.Assert;
4
+
5
+import java.util.Arrays;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class TestUtils {
11
+    public static <ObjectType> void assertArrayEquals(ObjectType[] array1, ObjectType[] array2) {
12
+        Arrays.sort(array1);
13
+        Arrays.sort(array2);
14
+        Assert.assertEquals(Arrays.toString(array1), Arrays.toString(array2));
15
+    }
16
+}

+ 43
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSentence.java Datei anzeigen

@@ -0,0 +1,43 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.piglatin;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import rocks.zipcode.io.quiz3.fundamentals.PigLatinGenerator;
7
+
8
+/**
9
+ * @author leon on 09/12/2018.
10
+ */
11
+public class TranslateSentence {
12
+    private PigLatinGenerator p;
13
+
14
+    @Before
15
+    public void setUp() throws Exception {
16
+        this.p = new PigLatinGenerator();
17
+    }
18
+
19
+    @Test
20
+    public void testTheQuickBrownFoxJumpsOverTheLazyDog() {
21
+        String input = "The Quick Brown Fox Jumps Over The Lazy Dog";
22
+        String expected = "eThay uickQay ownBray oxFay umpsJay Overway eThay azyLay ogDay";
23
+        String actual = p.translate(input);
24
+        Assert.assertEquals(expected, actual);
25
+    }
26
+    @Test
27
+    public void test_thequickbrownfoxjumpsoverthelazydog() {
28
+        String input = "The Quick Brown Fox Jumps Over The Lazy Dog".toLowerCase();
29
+        String expected = "eThay uickQay ownBray oxFay umpsJay Overway eThay azyLay ogDay".toLowerCase();
30
+        String actual = p.translate(input);
31
+        Assert.assertEquals(expected, actual);
32
+
33
+    }
34
+
35
+    @Test
36
+    public void testTHEQUICKBROWNFOXJUMPSOVERTHELAZYDOG() {
37
+        String input = "The Quick Brown Fox Jumps Over The Lazy Dog".toUpperCase();
38
+        String expected = "ETHay UICKQay OWNBRay OXFay UMPSJay OVERway ETHay AZYLay OGDay";
39
+        String actual = p.translate(input);
40
+        Assert.assertEquals(expected, actual);
41
+
42
+    }
43
+}

+ 55
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSingleWordStartingWithConsonant.java Datei anzeigen

@@ -0,0 +1,55 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.piglatin;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import rocks.zipcode.io.quiz3.fundamentals.PigLatinGenerator;
7
+
8
+/**
9
+ * @author leon on 09/12/2018.
10
+ *
11
+ */
12
+public class TranslateSingleWordStartingWithConsonant {
13
+    private PigLatinGenerator p;
14
+
15
+    @Before
16
+    public void setUp() {
17
+        this.p = new PigLatinGenerator();
18
+    }
19
+
20
+    @Test
21
+    public void testMap() {
22
+        Assert.assertEquals("apMay", p.translate("Map"));
23
+    }
24
+
25
+
26
+    @Test
27
+    public void testSpaghetti() {
28
+        Assert.assertEquals("aghettiSpay", p.translate("Spaghetti"));
29
+    }
30
+
31
+    @Test
32
+    public void testJava() {
33
+        Assert.assertEquals("avaJay", p.translate("Java"));
34
+    }
35
+
36
+    @Test
37
+    public void testPython() {
38
+        Assert.assertEquals("onPythay", p.translate("Python"));
39
+    }
40
+
41
+    @Test
42
+    public void testPsychosis() {
43
+        Assert.assertEquals("osisPsychay", p.translate("Psychosis"));
44
+    }
45
+
46
+    @Test
47
+    public void testPneumonia() {
48
+        Assert.assertEquals("eumoniaPnay", p.translate("Pneumonia"));
49
+    }
50
+
51
+    @Test
52
+    public void testRuby() {
53
+        Assert.assertEquals("ubyRay", p.translate("Ruby"));
54
+    }
55
+}

+ 28
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSingleWordStartingWithVowel.java Datei anzeigen

@@ -0,0 +1,28 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.piglatin;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import rocks.zipcode.io.quiz3.fundamentals.PigLatinGenerator;
7
+
8
+/**
9
+ * @author leon on 09/12/2018.
10
+ */
11
+public class TranslateSingleWordStartingWithVowel {
12
+    private PigLatinGenerator p;
13
+
14
+    @Before
15
+    public void setUp() throws Exception {
16
+        this.p = new PigLatinGenerator();
17
+    }
18
+
19
+    @Test
20
+    public void testegg() {
21
+        Assert.assertEquals("eggway", p.translate("egg"));
22
+    }
23
+
24
+    @Test
25
+    public void testCCC() {
26
+        Assert.assertEquals("CCCCay", p.translate("CCCC"));
27
+    }
28
+}

+ 7
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/stringutils/IsCharacterAtIndex.java Datei anzeigen

@@ -0,0 +1,7 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.stringutils;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class IsCharacterAtIndex {
7
+}

+ 7
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/vowelutils/GetIndexOfFirstVowel.java Datei anzeigen

@@ -0,0 +1,7 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.vowelutils;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class GetIndexOfFirstVowel {
7
+}

+ 7
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/vowelutils/HasVowels.java Datei anzeigen

@@ -0,0 +1,7 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.vowelutils;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class HasVowels {
7
+}

+ 7
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/vowelutils/IsVowel.java Datei anzeigen

@@ -0,0 +1,7 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.vowelutils;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class IsVowel {
7
+}

+ 7
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/vowelutils/StartsWithVowel.java Datei anzeigen

@@ -0,0 +1,7 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.vowelutils;
2
+
3
+/**
4
+ * @author leon on 09/12/2018.
5
+ */
6
+public class StartsWithVowel {
7
+}

+ 55
- 0
src/test/java/rocks/zipcode/io/quiz3/fundamentals/wavegenerator/WaveTest.java Datei anzeigen

@@ -0,0 +1,55 @@
1
+package rocks.zipcode.io.quiz3.fundamentals.wavegenerator;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.arrays.WaveGenerator;
6
+
7
+import java.util.Arrays;
8
+import java.util.function.Function;
9
+
10
+/**
11
+ * @author leon on 09/12/2018.
12
+ */
13
+public class WaveTest {
14
+    @Test
15
+    public void basicTest1() {
16
+        String stringToPermutate = "hello";
17
+        String[] input = new String[] { "Hello", "hEllo", "heLlo", "helLo", "hellO" };
18
+        evaluate(stringToPermutate, input, WaveGenerator::wave);
19
+    }
20
+
21
+    @Test
22
+    public void basicTest2() {
23
+        String stringToPermutate = "codewars";
24
+        String[] result = new String[] { "Codewars", "cOdewars", "coDewars", "codEwars", "codeWars", "codewArs", "codewaRs", "codewarS" };
25
+        evaluate(stringToPermutate, result, WaveGenerator::wave);
26
+    }
27
+
28
+    @Test
29
+    public void basicTest3() {
30
+        String stringToPermutate = "";
31
+        String[] result = new String[] { };
32
+        evaluate(stringToPermutate, result, WaveGenerator::wave);
33
+    }
34
+
35
+    @Test
36
+    public void basicTest4() {
37
+        String stringToPermutate = "two words";
38
+        String[] result = new String[] { "Two words", "tWo words", "twO words", "two Words", "two wOrds", "two woRds", "two worDs", "two wordS" };
39
+        evaluate(stringToPermutate, result, WaveGenerator::wave);
40
+    }
41
+
42
+    @Test
43
+    public void basicTest5() {
44
+        String stringToPermutate = " gap ";
45
+        String[] result = new String[] { " Gap ", " gAp ", " gaP " };
46
+        evaluate(stringToPermutate, result, WaveGenerator::wave);
47
+    }
48
+
49
+    public void evaluate(String stringToPermutate, String[] expected, Function<String, String[]> waveFunction) {
50
+        String[] actual = waveFunction.apply(stringToPermutate);
51
+        String actualStr = Arrays.toString(actual);
52
+        String expectedStr = Arrays.toString(expected);
53
+        Assert.assertEquals(expectedStr, actualStr);
54
+    }
55
+}

+ 87
- 0
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerFilterTest.java Datei anzeigen

@@ -0,0 +1,87 @@
1
+package rocks.zipcode.io.quiz3.generics.arrayutility.integer;
2
+
3
+import org.junit.Test;
4
+import rocks.zipcode.io.quiz3.TestUtils;
5
+import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6
+
7
+import java.util.function.Function;
8
+
9
+/**
10
+ * @author leon on 09/12/2018.
11
+ */
12
+public class IntegerFilterTest {
13
+    @Test
14
+    public void test1() {
15
+        // given
16
+        Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
17
+        Integer[] expected = new Integer[]{6, 7, 8, 9, 10};
18
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
19
+        Function<Integer, Boolean> predicate = val -> val > 5;
20
+
21
+        // when
22
+        Integer[] actual = utility.filter(predicate);
23
+
24
+        // then
25
+        TestUtils.assertArrayEquals(expected, actual);
26
+    }
27
+
28
+    @Test
29
+    public void test2() {
30
+        // given
31
+        Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
32
+        Integer[] expected = new Integer[]{};
33
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
34
+        Function<Integer, Boolean> predicate = val -> val > 50;
35
+
36
+        // when
37
+        Integer[] actual = utility.filter(predicate);
38
+
39
+        // then
40
+        TestUtils.assertArrayEquals(expected, actual);
41
+    }
42
+
43
+    @Test
44
+    public void test3() {
45
+        // given
46
+        Integer[] array = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
47
+        Integer[] expected = array;
48
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
49
+        Function<Integer, Boolean> predicate = val -> val < 50;
50
+
51
+        // when
52
+        Integer[] actual = utility.filter(predicate);
53
+
54
+        // then
55
+        TestUtils.assertArrayEquals(expected, actual);
56
+    }
57
+
58
+    @Test
59
+    public void test4() {
60
+        // given
61
+        Integer[] array = new Integer[]{10, 15, 20, 25, 55, 100, 150, 300, 900, 1000};
62
+        Integer[] expected = {10, 100, 1000};
63
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
64
+        Function<Integer, Boolean> predicate = val -> val.toString().startsWith("10");
65
+
66
+        // when
67
+        Integer[] actual = utility.filter(predicate);
68
+
69
+        // then
70
+        TestUtils.assertArrayEquals(expected, actual);
71
+    }
72
+
73
+    @Test
74
+    public void test5() {
75
+        // given
76
+        Integer[] array = new Integer[]{10, 15, 20, 25, 55, 100, 150, 300, 900, 1000};
77
+        Integer[] expected = {55, 15, 25};
78
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
79
+        Function<Integer, Boolean> predicate = val -> val.toString().endsWith("5");
80
+
81
+        // when
82
+        Integer[] actual = utility.filter(predicate);
83
+
84
+        // then
85
+        TestUtils.assertArrayEquals(expected, actual);
86
+    }
87
+}

+ 53
- 0
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerFindEvenOccurringValue.java Datei anzeigen

@@ -0,0 +1,53 @@
1
+package rocks.zipcode.io.quiz3.generics.arrayutility.integer;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class IntegerFindEvenOccurringValue {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        Integer expected = 5;
15
+        Integer[] array = new Integer[]{1, 2, 3, 4, expected, expected};
16
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
17
+
18
+        // when
19
+        Integer actual = utility.findEvenOccurringValue();
20
+
21
+        // then
22
+        Assert.assertEquals(expected, actual);
23
+    }
24
+
25
+    @Test
26
+    public void test2() {
27
+        // given
28
+        Integer expected = 18;
29
+        Integer[] array = new Integer[]{1, 1, 1, 2, 2, 2, 2, 2, expected, 4, 4, 4, expected, expected, expected};
30
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
31
+
32
+        // when
33
+        Integer actual = utility.findEvenOccurringValue();
34
+
35
+        // then
36
+        Assert.assertEquals(expected, actual);
37
+    }
38
+
39
+
40
+    @Test
41
+    public void test3() {
42
+        // given
43
+        Integer expected = 30;
44
+        Integer[] array = new Integer[]{1, expected, 4, expected, expected, 10, 10, 10, expected, expected, expected};
45
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
46
+
47
+        // when
48
+        Integer actual = utility.findEvenOccurringValue();
49
+
50
+        // then
51
+        Assert.assertEquals(expected, actual);
52
+    }
53
+}

+ 53
- 0
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerFindOddOccurringValue.java Datei anzeigen

@@ -0,0 +1,53 @@
1
+package rocks.zipcode.io.quiz3.generics.arrayutility.integer;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class IntegerFindOddOccurringValue {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        Integer expected = 5;
15
+        Integer[] array = new Integer[]{1, 1, 2, 2, 3, 3, expected, expected, expected};
16
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
17
+
18
+        // when
19
+        Integer actual = utility.findOddOccurringValue();
20
+
21
+        // then
22
+        Assert.assertEquals(expected, actual);
23
+    }
24
+
25
+    @Test
26
+    public void test2() {
27
+        // given
28
+        Integer expected = 18;
29
+        Integer[] array = new Integer[]{1, 1, 6, 6, 9, 9, expected, expected, expected, expected, expected};
30
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
31
+
32
+        // when
33
+        Integer actual = utility.findOddOccurringValue();
34
+
35
+        // then
36
+        Assert.assertEquals(expected, actual);
37
+    }
38
+
39
+
40
+    @Test
41
+    public void test3() {
42
+        // given
43
+        Integer expected = 30;
44
+        Integer[] array = new Integer[]{11, 11, 11, 11, 20, 20, 27, 27, 27, 27, expected, expected, expected, expected, expected, expected, expected};
45
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
46
+
47
+        // when
48
+        Integer actual = utility.findOddOccurringValue();
49
+
50
+        // then
51
+        Assert.assertEquals(expected, actual);
52
+    }
53
+}

+ 56
- 0
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/integer/IntegerGetNumberOfOccurrences.java Datei anzeigen

@@ -0,0 +1,56 @@
1
+package rocks.zipcode.io.quiz3.generics.arrayutility.integer;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class IntegerGetNumberOfOccurrences {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        Integer expected = 2;
15
+        Integer valueToEvaluate = 5;
16
+        Integer[] array = new Integer[]{1, 2, 3, 4, valueToEvaluate, valueToEvaluate};
17
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
18
+
19
+        // when
20
+        Integer actual = utility.getNumberOfOccurrences(valueToEvaluate);
21
+
22
+        // then
23
+        Assert.assertEquals(expected, actual);
24
+    }
25
+
26
+    @Test
27
+    public void test2() {
28
+        // given
29
+        Integer expected = 4;
30
+        Integer valueToEvaluate = 18;
31
+        Integer[] array = new Integer[]{1, 1, 1, 2, 2, 2, 2, 2, valueToEvaluate, 4, 4, 4, valueToEvaluate, valueToEvaluate, valueToEvaluate};
32
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
33
+
34
+        // when
35
+        Integer actual = utility.getNumberOfOccurrences(valueToEvaluate);
36
+
37
+        // then
38
+        Assert.assertEquals(expected, actual);
39
+    }
40
+
41
+
42
+    @Test
43
+    public void test3() {
44
+        // given
45
+        Integer expected = 6;
46
+        Integer valueToEvaluate = 30;
47
+        Integer[] array = new Integer[]{1, valueToEvaluate, 4, valueToEvaluate, valueToEvaluate, 10, 10, 10, valueToEvaluate, valueToEvaluate, valueToEvaluate};
48
+        ArrayUtility<Integer> utility = new ArrayUtility<>(array);
49
+
50
+        // when
51
+        Integer actual = utility.findEvenOccurringValue();
52
+
53
+        // then
54
+        Assert.assertEquals(expected, actual);
55
+    }
56
+}

+ 52
- 0
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFilterTest.java Datei anzeigen

@@ -0,0 +1,52 @@
1
+package rocks.zipcode.io.quiz3.generics.arrayutility.string;
2
+
3
+import org.junit.Test;
4
+import rocks.zipcode.io.quiz3.TestUtils;
5
+import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class StringFilterTest {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        String[] expected = {"quick", "brown", "jumps", "over", "lazy"};
15
+        String[] input = "The quick brown fox jumps over the lazy dog".split(" ");
16
+        ArrayUtility<String> utility = new ArrayUtility<>(input);
17
+
18
+        // when
19
+        String[] actual = utility.filter(string -> string.length() > 3);
20
+
21
+        // then
22
+        TestUtils.assertArrayEquals(expected, actual);
23
+    }
24
+
25
+    @Test
26
+    public void test2() {
27
+        // given
28
+        String[] expected = {"The", "fox", "the", "dog"};
29
+        String[] input = "The quick brown fox jumps over the lazy dog".split(" ");
30
+        ArrayUtility<String> utility = new ArrayUtility<>(input);
31
+
32
+        // when
33
+        String[] actual = utility.filter(string -> string.length() < 3);
34
+
35
+        // then
36
+        TestUtils.assertArrayEquals(expected, actual);
37
+    }
38
+
39
+    @Test
40
+    public void test3() {
41
+        // given
42
+        String[] expected = {"The", "over", "the"};
43
+        String[] input = "The quick brown fox jumps over the lazy dog".split(" ");
44
+        ArrayUtility<String> utility = new ArrayUtility<>(input);
45
+
46
+        // when
47
+        String[] actual = utility.filter(string -> string.contains("e"));
48
+
49
+        // then
50
+        TestUtils.assertArrayEquals(expected, actual);
51
+    }
52
+}

+ 47
- 0
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFindEvenOccurringValueTest.java Datei anzeigen

@@ -0,0 +1,47 @@
1
+package rocks.zipcode.io.quiz3.generics.arrayutility.string;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class StringFindEvenOccurringValueTest {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        String expected = "Zip";
15
+        String[] array = {expected, expected, "Code", "Code", "Code", "Wilmington"};
16
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
17
+
18
+        // when
19
+        String actual = utility.findEvenOccurringValue();
20
+        Assert.assertEquals(expected, actual);
21
+    }
22
+
23
+    @Test
24
+    public void test2() {
25
+        // given
26
+        String expected = "(-_-)";
27
+        String[] array = {expected, expected, "Code", "Code", "Code", expected, expected, "Wilmington"};
28
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
29
+
30
+        // when
31
+        String actual = utility.findEvenOccurringValue();
32
+        Assert.assertEquals(expected, actual);
33
+    }
34
+
35
+    @Test
36
+    public void test3() {
37
+        // given
38
+        String expected = "Code";
39
+        String[] array = {"Zip", "Zip", "Zip", expected, expected, expected, "Wilmington", expected, expected, expected};
40
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
41
+
42
+        // when
43
+        String actual = utility.findEvenOccurringValue();
44
+        Assert.assertEquals(expected, actual);
45
+    }
46
+
47
+}

+ 46
- 0
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringFindOddOccurringValueTest.java Datei anzeigen

@@ -0,0 +1,46 @@
1
+package rocks.zipcode.io.quiz3.generics.arrayutility.string;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class StringFindOddOccurringValueTest {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        String expected = "Wilmington";
15
+        String[] array = {expected, expected, expected, "Code", "Code", "Code", "Code", "Zip", "Zip"};
16
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
17
+
18
+        // when
19
+        String actual = utility.findEvenOccurringValue();
20
+        Assert.assertEquals(expected, actual);
21
+    }
22
+
23
+    @Test
24
+    public void test2() {
25
+        // given
26
+        String expected = "(-_-)";
27
+        String[] array = {expected, expected, expected, "Code", "Code", "Code", "Code", expected, expected, "Wilmington", "Wilmington"};
28
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
29
+
30
+        // when
31
+        String actual = utility.findEvenOccurringValue();
32
+        Assert.assertEquals(expected, actual);
33
+    }
34
+
35
+    @Test
36
+    public void test3() {
37
+        // given
38
+        String expected = "Code";
39
+        String[] array = {"Zip", "Zip", "Zip", "Zip", "Zip", "Zip", expected, expected, expected, expected, "Wilmington", "Wilmington", expected, expected, expected};
40
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
41
+
42
+        // when
43
+        String actual = utility.findEvenOccurringValue();
44
+        Assert.assertEquals(expected, actual);
45
+    }
46
+}

+ 49
- 0
src/test/java/rocks/zipcode/io/quiz3/generics/arrayutility/string/StringGetNumberOfOccurrencesTest.java Datei anzeigen

@@ -0,0 +1,49 @@
1
+package rocks.zipcode.io.quiz3.generics.arrayutility.string;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.generics.ArrayUtility;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class StringGetNumberOfOccurrencesTest {
11
+    @Test
12
+    public void test1() {
13
+        // given
14
+        Integer expected = 3;
15
+        String stringToEvaluate = "Wilmington";
16
+        String[] array = {stringToEvaluate, stringToEvaluate, stringToEvaluate, "Code", "Code", "Code", "Code", "Zip", "Zip"};
17
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
18
+
19
+        // when
20
+        Integer actual = utility.getNumberOfOccurrences(stringToEvaluate);
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+
24
+    @Test
25
+    public void test2() {
26
+        // given
27
+        Integer expected = 5;
28
+        String stringToEvaluate = "(-_-)";
29
+        String[] array = {stringToEvaluate, stringToEvaluate, stringToEvaluate, "Code", "Code", "Code", "Code", stringToEvaluate, stringToEvaluate, "Wilmington", "Wilmington"};
30
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
31
+
32
+        // when
33
+        Integer actual = utility.getNumberOfOccurrences(stringToEvaluate);
34
+        Assert.assertEquals(expected, actual);
35
+    }
36
+
37
+    @Test
38
+    public void test3() {
39
+        // given
40
+        Integer expectedd = 7;
41
+        String stringToEvaluate = "Code";
42
+        String[] array = {"Zip", "Zip", "Zip", "Zip", "Zip", "Zip", stringToEvaluate, stringToEvaluate, stringToEvaluate, stringToEvaluate, "Wilmington", "Wilmington", stringToEvaluate, stringToEvaluate, stringToEvaluate};
43
+        ArrayUtility<String> utility = new ArrayUtility<>(array);
44
+
45
+        // when
46
+        Integer actual = utility.getNumberOfOccurrences(stringToEvaluate);
47
+        Assert.assertEquals(stringToEvaluate, actual);
48
+    }
49
+}

+ 31
- 0
src/test/java/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/PaperTest.java Datei anzeigen

@@ -0,0 +1,31 @@
1
+package rocks.zipcode.io.quiz3.objectorientation.enums.rockpaperscissors;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import rocks.zipcode.io.quiz3.objectorientation.enums.RockPaperScissorHandSign;
7
+
8
+/**
9
+ * @author leon on 09/12/2018.
10
+ */
11
+public class PaperTest {
12
+    private RockPaperScissorHandSign sign;
13
+
14
+    @Before
15
+    public void setup() {
16
+        // given
17
+        this.sign = RockPaperScissorHandSign.valueOf("PAPER");
18
+    }
19
+
20
+    @Test
21
+    public void testGetLoser() {
22
+        RockPaperScissorHandSign loser = RockPaperScissorHandSign.valueOf("ROCK");
23
+        Assert.assertEquals(loser, sign.getLoser());
24
+    }
25
+
26
+    @Test
27
+    public void testGetWinner() {
28
+        RockPaperScissorHandSign loser = RockPaperScissorHandSign.valueOf("SCISSORS");
29
+        Assert.assertEquals(loser, sign.getLoser());
30
+    }
31
+}

+ 32
- 0
src/test/java/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/RockTest.java Datei anzeigen

@@ -0,0 +1,32 @@
1
+package rocks.zipcode.io.quiz3.objectorientation.enums.rockpaperscissors;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import rocks.zipcode.io.quiz3.objectorientation.enums.RockPaperScissorHandSign;
7
+
8
+/**
9
+ * @author leon on 09/12/2018.
10
+ */
11
+public class RockTest {
12
+    private RockPaperScissorHandSign sign;
13
+
14
+    @Before
15
+    public void setup() {
16
+        // given
17
+        this.sign = RockPaperScissorHandSign.valueOf("ROCK");
18
+    }
19
+
20
+
21
+    @Test
22
+    public void testGetLoser() {
23
+        RockPaperScissorHandSign loser = RockPaperScissorHandSign.valueOf("SCISSORS");
24
+        Assert.assertEquals(loser, sign.getLoser());
25
+    }
26
+
27
+    @Test
28
+    public void testGetWinner() {
29
+        RockPaperScissorHandSign loser = RockPaperScissorHandSign.valueOf("PAPER");
30
+        Assert.assertEquals(loser, sign.getLoser());
31
+    }
32
+}

+ 31
- 0
src/test/java/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/ScissorTest.java Datei anzeigen

@@ -0,0 +1,31 @@
1
+package rocks.zipcode.io.quiz3.objectorientation.enums.rockpaperscissors;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import rocks.zipcode.io.quiz3.objectorientation.enums.RockPaperScissorHandSign;
6
+
7
+/**
8
+ * @author leon on 09/12/2018.
9
+ */
10
+public class ScissorTest {
11
+    private RockPaperScissorHandSign sign;
12
+
13
+    @Test
14
+    public void setup() {
15
+        // given
16
+        this.sign = RockPaperScissorHandSign.valueOf("SCISSOR");
17
+    }
18
+
19
+
20
+    @Test
21
+    public void testGetLoser() {
22
+        RockPaperScissorHandSign loser = RockPaperScissorHandSign.valueOf("PAPER");
23
+        Assert.assertEquals(loser, sign.getLoser());
24
+    }
25
+
26
+    @Test
27
+    public void testGetWinner() {
28
+        RockPaperScissorHandSign loser = RockPaperScissorHandSign.valueOf("ROCK");
29
+        Assert.assertEquals(loser, sign.getLoser());
30
+    }
31
+}

BIN
target/classes/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/arrays/TicTacToe.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/arrays/WaveGenerator.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/collections/Person.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/collections/Shoe.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/collections/ShoeFitter.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/collections/ShoeSize.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/fundamentals/PigLatinGenerator.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/fundamentals/StringUtils.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/fundamentals/VowelUtils.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/generics/ArrayUtility.class Datei anzeigen


BIN
target/classes/rocks/zipcode/io/quiz3/objectorientation/enums/RockPaperScissorHandSign.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSentence.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSingleWordStartingWithConsonant.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/piglatin/TranslateSingleWordStartingWithVowel.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/stringutils/IsCharacterAtIndex.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/vowelutils/GetIndexOfFirstVowel.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/vowelutils/HasVowels.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/vowelutils/IsVowel.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/vowelutils/StartsWithVowel.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/fundamentals/wavegenerator/WaveTest.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/PaperTest.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/RockTest.class Datei anzeigen


BIN
target/test-classes/rocks/zipcode/io/quiz3/objectorientation/enums/rockpaperscissors/ScissorTest.class Datei anzeigen