Leon il y a 6 ans
Parent
révision
6f99fe85e7
24 fichiers modifiés avec 1342 ajouts et 0 suppressions
  1. 57
    0
      .gitignore
  2. 1
    0
      .idea/.name
  3. 16
    0
      .idea/compiler.xml
  4. 7
    0
      .idea/kotlinc.xml
  5. 90
    0
      .idea/misc.xml
  6. 8
    0
      .idea/modules.xml
  7. 6
    0
      .idea/vcs.xml
  8. 16
    0
      ChapterOneMicro.iml
  9. 78
    0
      README.md
  10. 35
    0
      pom.xml
  11. 240
    0
      src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java
  12. 42
    0
      src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java
  13. 88
    0
      src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java
  14. 344
    0
      src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestMathUtilities.java
  15. 121
    0
      src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestPredicateUtilities.java
  16. 176
    0
      src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.java
  17. 17
    0
      src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestSuite.java
  18. BIN
      target/classes/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.class
  19. BIN
      target/classes/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.class
  20. BIN
      target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class
  21. BIN
      target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestMathUtilities.class
  22. BIN
      target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestPredicateUtilities.class
  23. BIN
      target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.class
  24. BIN
      target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestSuite.class

+ 57
- 0
.gitignore Voir le fichier

@@ -0,0 +1,57 @@
1
+er-specific stuff:
2
+.idea/**/workspace.xml
3
+.idea/**/tasks.xml
4
+.idea/dictionaries
5
+
6
+# Sensitive or high-churn files:
7
+.idea/**/dataSources/
8
+.idea/**/dataSources.ids
9
+.idea/**/dataSources.xml
10
+.idea/**/dataSources.local.xml
11
+.idea/**/sqlDataSources.xml
12
+.idea/**/dynamic.xml
13
+.idea/**/uiDesigner.xml
14
+
15
+# Gradle:
16
+.idea/**/gradle.xml
17
+.idea/**/libraries
18
+
19
+# CMake
20
+cmake-build-debug/
21
+
22
+# Mongo Explorer plugin:
23
+.idea/**/mongoSettings.xml
24
+
25
+## File-based project format:
26
+*.iws
27
+
28
+## Plugin-specific files:
29
+
30
+# IntelliJ
31
+/out/
32
+
33
+# mpeltonen/sbt-idea plugin
34
+.idea_modules/
35
+
36
+# JIRA plugin
37
+atlassian-ide-plugin.xml
38
+
39
+# Cursive Clojure plugin
40
+.idea/replstate.xml
41
+
42
+# Crashlytics plugin (for Android Studio and IntelliJ)
43
+com_crashlytics_export_strings.xml
44
+crashlytics.properties
45
+crashlytics-build.properties
46
+fabric.properties
47
+
48
+### Intellij Patch ###
49
+# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
50
+
51
+# *.iml
52
+# modules.xml
53
+# .idea/misc.xml
54
+# *.ipr
55
+
56
+# Sonarlint plugin
57
+.idea/sonarlint

+ 1
- 0
.idea/.name Voir le fichier

@@ -0,0 +1 @@
1
+ChapterOneMicro

+ 16
- 0
.idea/compiler.xml Voir le fichier

@@ -0,0 +1,16 @@
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="ChapterOneMicro" />
10
+      </profile>
11
+    </annotationProcessing>
12
+    <bytecodeTargetLevel target="1.8">
13
+      <module name="ChapterOneMicro" target="1.8" />
14
+    </bytecodeTargetLevel>
15
+  </component>
16
+</project>

+ 7
- 0
.idea/kotlinc.xml Voir le fichier

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="KotlinCommonCompilerArguments">
4
+    <option name="languageVersion" value="1.1" />
5
+    <option name="apiVersion" value="1.1" />
6
+  </component>
7
+</project>

+ 90
- 0
.idea/misc.xml Voir le fichier

@@ -0,0 +1,90 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="MavenProjectsManager">
4
+    <option name="originalFiles">
5
+      <list>
6
+        <option value="$PROJECT_DIR$/pom.xml" />
7
+      </list>
8
+    </option>
9
+  </component>
10
+  <component name="ProjectInspectionProfilesVisibleTreeState">
11
+    <entry key="Project Default">
12
+      <profile-state>
13
+        <expanded-state>
14
+          <State>
15
+            <id />
16
+          </State>
17
+        </expanded-state>
18
+        <selected-state>
19
+          <State>
20
+            <id>Android</id>
21
+          </State>
22
+        </selected-state>
23
+      </profile-state>
24
+    </entry>
25
+  </component>
26
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
27
+    <output url="file://$PROJECT_DIR$/classes" />
28
+  </component>
29
+  <component name="masterDetails">
30
+    <states>
31
+      <state key="GlobalLibrariesConfigurable.UI">
32
+        <settings>
33
+          <splitter-proportions>
34
+            <option name="proportions">
35
+              <list>
36
+                <option value="0.2" />
37
+              </list>
38
+            </option>
39
+          </splitter-proportions>
40
+        </settings>
41
+      </state>
42
+      <state key="JdkListConfigurable.UI">
43
+        <settings>
44
+          <last-edited>1.8</last-edited>
45
+          <splitter-proportions>
46
+            <option name="proportions">
47
+              <list>
48
+                <option value="0.2" />
49
+              </list>
50
+            </option>
51
+          </splitter-proportions>
52
+        </settings>
53
+      </state>
54
+      <state key="ProjectJDKs.UI">
55
+        <settings>
56
+          <last-edited>1.8</last-edited>
57
+          <splitter-proportions>
58
+            <option name="proportions">
59
+              <list>
60
+                <option value="0.2" />
61
+              </list>
62
+            </option>
63
+          </splitter-proportions>
64
+        </settings>
65
+      </state>
66
+      <state key="ProjectLibrariesConfigurable.UI">
67
+        <settings>
68
+          <splitter-proportions>
69
+            <option name="proportions">
70
+              <list>
71
+                <option value="0.2" />
72
+              </list>
73
+            </option>
74
+          </splitter-proportions>
75
+        </settings>
76
+      </state>
77
+      <state key="ScopeChooserConfigurable.UI">
78
+        <settings>
79
+          <splitter-proportions>
80
+            <option name="proportions">
81
+              <list>
82
+                <option value="0.2" />
83
+              </list>
84
+            </option>
85
+          </splitter-proportions>
86
+        </settings>
87
+      </state>
88
+    </states>
89
+  </component>
90
+</project>

+ 8
- 0
.idea/modules.xml Voir le fichier

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/ChapterOneMicro.iml" filepath="$PROJECT_DIR$/ChapterOneMicro.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 6
- 0
.idea/vcs.xml Voir le fichier

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+  </component>
6
+</project>

+ 16
- 0
ChapterOneMicro.iml Voir le fichier

@@ -0,0 +1,16 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
4
+    <output url="file://$MODULE_DIR$/target/classes" />
5
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
+    <content url="file://$MODULE_DIR$">
7
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
9
+      <excludeFolder url="file://$MODULE_DIR$/target" />
10
+    </content>
11
+    <orderEntry type="inheritedJdk" />
12
+    <orderEntry type="sourceFolder" forTests="false" />
13
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
14
+    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
15
+  </component>
16
+</module>

+ 78
- 0
README.md Voir le fichier

@@ -0,0 +1,78 @@
1
+# Java Fundamentals
2
+* **Objective:**
3
+    * To complete the method stubs in each of the provided classes
4
+        * `MathUtilities`
5
+    	* `PredicateUtilities`
6
+    	* `StringUtilities`
7
+
8
+* **Purpose:**
9
+    * To establish familiarity with
10
+        * [primitive data-types](http://cs.fit.edu/~ryan/java/language/java-data.html)
11
+        * [method signatures and return statements](http://www.homeandlearn.co.uk/java/java_methods.html)
12
+        * [String operations](https://www.tutorialspoint.com/java/java_strings.htm)
13
+    
14
+* **Classes to be completed:**
15
+	* `MathUtilities`
16
+	* `PredicateUtilities`
17
+	* `StringUtilities`
18
+	
19
+* **Instructions**
20
+    * Complete each of the method stubs in the `main` classes provided.
21
+        * `main` classes are located in `src.main.java.com.zipcodewilmington.danny_do_better_exercises`
22
+    * There are comments above each method stub to describe the expected behavior.
23
+    * Upon completion, open and run the `TestSuite` class to ensure that all tests have 100% success.
24
+        * `TestSuite` is located in `src.test.java.com.zipcodewilmington.danny_do_better_exercises`
25
+
26
+## Predicate Utilities
27
+* A _predicate_ is a clause which states something about a subject. (_e.g., **is assigning**_ in _"Leon **is assigning** homework"_)
28
+* Ensure each of the test cases passes successfully in the class [TestPredicateUtilities](./src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestPredicateUtilities.java) by completing each of the method stubs in the class [PredicateUtilities](./src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java).
29
+* Method Stubs to be completed
30
+	* `boolean isGreaterThan(int x, int y)`
31
+	* `boolean isLessThan(int x, int y)`
32
+	* `boolean isGreaterThanOrEqualTo(int x, int y)`
33
+	* `boolean isLessThanOrEqualTo(int x, int y)`
34
+
35
+
36
+## Math Utilities
37
+* Ensure each of the test cases passes successfully in the class [TestMathUtilities](./src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestMathUtilities.java) by completing each of the method stubs in the class [MathUtilities](./src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java).
38
+* Method Stubs to be completed	
39
+	* `Integer add(int, int)`
40
+	* `Long add(long, long)`
41
+	* `Short add(short, short)`
42
+	* `Byte add(byte, byte)`
43
+	* `Float add(float, float)`
44
+	* `Double add(double, double)`
45
+	* `Integer subtract(int, int)`
46
+	* `Long subtract(long, long)`
47
+	* `Short subtract(short, short)`
48
+	* `Byte subtract(byte, byte)`
49
+	* `Float subtract(float, float)`
50
+	* `Double subtract(double, double)`
51
+	* `Integer divide(int, int)`
52
+	* `Long divide(long, long)`
53
+	* `Short divide(short, short)`
54
+	* `Byte divide(byte, byte)`
55
+	* `Float divide(float, float)`
56
+	* `Double divide(double, double)`
57
+	* `Integer multiply(int, int)`
58
+	* `Long multiply(long, long)`
59
+	* `Short multiply(short, short)`
60
+	* `Byte multiply(byte, byte)`
61
+	* `Float multiply(float, float)`
62
+	* `Double multiply(double, double)`
63
+	* `Boolean returnTrue`
64
+	* `Boolean returnFalse`
65
+
66
+
67
+## String Utilities
68
+* Ensure each of the test cases passes successfully in the class [TestStringUtilities](./src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.java) by completing each of the method stubs in the class [StringUtilities](./src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java).
69
+* Method Stubs to be completed
70
+	* `String concatenation(String, String)`
71
+	* `String concatenation(int, String)`
72
+	* `String getPrefix(String)`
73
+	* `String getSuffix(String)`
74
+	* `String compareTwoStrings(String)`
75
+	* `Character getMiddleCharacter(String)`
76
+	* `String getFirstWord(String)`
77
+	* `String getSecondWord(String)`
78
+	* `String reverseTheTwo(String)`

+ 35
- 0
pom.xml Voir le fichier

@@ -0,0 +1,35 @@
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>zipcoder.io</groupId>
8
+    <artifactId>ChapterOneMicro</artifactId>
9
+    <version>1.0-SNAPSHOT</version>
10
+
11
+    <dependencies>
12
+        <dependency>
13
+            <groupId>junit</groupId>
14
+            <artifactId>junit</artifactId>
15
+            <version>4.12</version>
16
+            <scope>test</scope>
17
+        </dependency>
18
+    </dependencies>
19
+
20
+    <build>
21
+        <plugins>
22
+            <plugin>
23
+                <groupId>org.apache.maven.plugins</groupId>
24
+                <artifactId>maven-compiler-plugin</artifactId>
25
+                <version>3.6.0</version>
26
+                <configuration>
27
+                    <source>1.8</source>
28
+                    <target>1.8</target>
29
+                </configuration>
30
+            </plugin>
31
+        </plugins>
32
+    </build>
33
+
34
+
35
+</project>

+ 240
- 0
src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java Voir le fichier

@@ -0,0 +1,240 @@
1
+package com.zipcodewilmington.danny_do_better_exercises;
2
+
3
+/**
4
+ * Created by dan on 6/14/17.
5
+ */
6
+public class MathUtilities {
7
+
8
+    /**
9
+     * @param baseValue  starting value
10
+     * @param difference value to add to starting value
11
+     * @return sum of `baseValue` and `difference`
12
+     */
13
+    public Integer add(int baseValue, int difference) {
14
+        return null;
15
+    }
16
+
17
+    /**
18
+     * @param baseValue  starting value
19
+     * @param difference value to add to starting value
20
+     * @return sum of `baseValue` and `difference`
21
+     */
22
+    public Long add(long baseValue, long difference) {
23
+        return null;
24
+    }
25
+
26
+    /**
27
+     * @param baseValue  starting value
28
+     * @param difference value to add to starting value
29
+     * @return sum of `baseValue` and `difference`
30
+     */
31
+    public Short add(short baseValue, short difference) {
32
+        return null;
33
+    }
34
+
35
+    /**
36
+     * @param baseValue  starting value
37
+     * @param difference value to add to starting value
38
+     * @return sum of `baseValue` and `difference`
39
+     */
40
+    public Byte add(byte baseValue, byte difference) {
41
+        return null;
42
+    }
43
+
44
+    /**
45
+     * @param baseValue  starting value
46
+     * @param difference value to add to starting value
47
+     * @return sum of `baseValue` and `difference`
48
+     */
49
+    public Float add(float baseValue, float difference) {
50
+        return null;
51
+    }
52
+
53
+    /**
54
+     * @param baseValue  starting value
55
+     * @param difference value to add to starting value
56
+     * @return sum of `baseValue` and `difference`
57
+     */
58
+    public Double add(double baseValue, double difference) {
59
+        return null;
60
+    }
61
+
62
+    /**
63
+     * @param baseValue  starting value
64
+     * @param difference value to subtract from starting value
65
+     * @return difference between `baseValue` and `difference`
66
+     */
67
+    public Integer subtract(int baseValue, int difference) {
68
+        return null;
69
+    }
70
+
71
+    /**
72
+     * @param baseValue  starting value
73
+     * @param difference value to subtract from starting value
74
+     * @return difference between `baseValue` and `difference`
75
+     */
76
+    public Long subtract(long baseValue, long difference) {
77
+        return null;
78
+    }
79
+
80
+    /**
81
+     * @param baseValue  starting value
82
+     * @param difference value to subtract from starting value
83
+     * @return difference between `baseValue` and `difference`
84
+     */
85
+    public Short subtract(short baseValue, short difference) {
86
+        return null;
87
+    }
88
+
89
+    /**
90
+     * @param baseValue  starting value
91
+     * @param difference value to subtract from starting value
92
+     * @return difference between `baseValue` and `difference`
93
+     */
94
+    public Byte subtract(byte baseValue, byte difference) {
95
+        return null;
96
+    }
97
+
98
+    /**
99
+     * @param baseValue  starting value
100
+     * @param difference value to subtract from starting value
101
+     * @return difference between `baseValue` and `difference`
102
+     */
103
+    public Float subtract(float baseValue, float difference) {
104
+        return null;
105
+    }
106
+
107
+    /**
108
+     * @param baseValue  starting value
109
+     * @param difference value to subtract from starting value
110
+     * @return difference between `baseValue` and `difference`
111
+     */
112
+    public Double subtract(double baseValue, double difference) {
113
+        return null;
114
+    }
115
+
116
+
117
+    /**
118
+     * @param dividend value to be divided
119
+     * @param divisor value to divide by
120
+     * @return division of `dividend` by `divisor
121
+     */
122
+    public Integer divide(int dividend, int divisor) {
123
+        return null;
124
+    }
125
+
126
+    /**
127
+     * @param dividend value to be divided
128
+     * @param divisor value to divide by
129
+     * @return division of `dividend` by `divisor
130
+     */
131
+    public Long divide(long dividend, long divisor) {
132
+        return null;
133
+    }
134
+
135
+    /**
136
+     * @param dividend value to be divided
137
+     * @param divisor value to divide by
138
+     * @return division of `dividend` by `divisor
139
+     */
140
+    public Short divide(short dividend, short divisor) {
141
+        return null;
142
+    }
143
+
144
+    /**
145
+     * @param dividend value to be divided
146
+     * @param divisor value to divide by
147
+     * @return division of `dividend` by `divisor
148
+     */
149
+    public Byte divide(byte dividend, byte divisor) {
150
+        return null;
151
+    }
152
+
153
+    /**
154
+     * @param dividend value to be divided
155
+     * @param divisor value to divide by
156
+     * @return division of `dividend` by `divisor
157
+     */
158
+    public Float divide(float dividend, float divisor) {
159
+        return null;
160
+    }
161
+
162
+    /**
163
+     * @param dividend value to be divided
164
+     * @param divisor value to divide by
165
+     * @return division of `dividend` by `divisor
166
+     */
167
+    public Double divide(double dividend, double divisor) {
168
+        return null;
169
+    }
170
+
171
+
172
+    /**
173
+     * @param multiplicand value to be multiplied
174
+     * @param multiplier value to multiply by
175
+     * @return product of `multiplicand` by `multiplier`
176
+     */
177
+    public Integer multiply(int multiplicand, int multiplier) {
178
+        return null;
179
+    }
180
+
181
+    /**
182
+     * @param multiplicand value to be multiplied
183
+     * @param multiplier value to multiply by
184
+     * @return product of `multiplicand` by `multiplier`
185
+     */
186
+    public Long multiply(long multiplicand, long multiplier) {
187
+        return null;
188
+    }
189
+
190
+    /**
191
+     * @param multiplicand value to be multiplied
192
+     * @param multiplier value to multiply by
193
+     * @return product of `multiplicand` by `multiplier`
194
+     */
195
+    public Short multiply(short multiplicand, short multiplier) {
196
+        return null;
197
+    }
198
+    /**
199
+     * @param multiplicand value to be multiplied
200
+     * @param multiplier value to multiply by
201
+     * @return product of `multiplicand` by `multiplier`
202
+     */
203
+    public Byte multiply(byte multiplicand, byte multiplier) {
204
+        return null;
205
+    }
206
+
207
+    /**
208
+     * @param multiplicand value to be multiplied
209
+     * @param multiplier value to multiply by
210
+     * @return product of `multiplicand` by `multiplier`
211
+     */
212
+    public Float multiply(float multiplicand, float multiplier) {
213
+        return null;
214
+    }
215
+
216
+    /**
217
+     * @param multiplicand value to be multiplied
218
+     * @param multiplier value to multiply by
219
+     * @return product of `multiplicand` by `multiplier`
220
+     */
221
+    public Double multiply(double multiplicand, double multiplier) {
222
+        return null;
223
+    }
224
+
225
+
226
+    /**
227
+      * @return true
228
+     */
229
+    public Boolean returnTrue() {
230
+        return null;
231
+    }
232
+
233
+    /**
234
+     * @return false
235
+     */
236
+    public Boolean returnFalse() {
237
+        return null;
238
+    }
239
+
240
+}

+ 42
- 0
src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java Voir le fichier

@@ -0,0 +1,42 @@
1
+package com.zipcodewilmington.danny_do_better_exercises;
2
+
3
+/**
4
+ * Created by dan on 6/14/17.
5
+ */
6
+public class PredicateUtilities {
7
+    /**
8
+     * @param x
9
+     * @param y
10
+     * @return true if `x` is greater than `y`
11
+     */
12
+    public Boolean isGreaterThan(int x, int y) {
13
+        return null;
14
+    }
15
+
16
+    /**
17
+     * @param x
18
+     * @param y
19
+     * @return true if `x` is less than `y`
20
+     */
21
+    public Boolean isLessThan(int x, int y) {
22
+        return null;
23
+    }
24
+
25
+    /**
26
+     * @param x
27
+     * @param y
28
+     * @return true if `x` is greater than or equal to `y`
29
+     */
30
+    public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
+        return null;
32
+    }
33
+
34
+    /**
35
+     * @param x
36
+     * @param y
37
+     * @return true if `x` is less than or equal to `y`
38
+     */
39
+    public Boolean isLessThanOrEqualTo(int x, int y) {
40
+        return null;
41
+    }
42
+}

+ 88
- 0
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java Voir le fichier

@@ -0,0 +1,88 @@
1
+package com.zipcodewilmington.danny_do_better_exercises;
2
+
3
+/**
4
+ * Created by dan on 6/14/17.
5
+ */
6
+public class StringUtilities {
7
+    /**
8
+     * @return `Hello World` as a string
9
+     */
10
+    public static String getHelloWorld() {
11
+        return null;
12
+    }
13
+
14
+    /**
15
+     * @param firstSegment a string to be added to
16
+     * @param secondSegment a string to add
17
+     * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18
+     */
19
+    public static String concatenation(String firstSegment, String secondSegment){
20
+        return null;
21
+    }
22
+
23
+    /**
24
+     * @param firstSegment a string to be added to
25
+     * @param secondSegment a string to add
26
+     * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27
+     */
28
+    public static String concatenation(int firstSegment, String secondSegment){
29
+        return null;
30
+    }
31
+
32
+    /**
33
+     * @param input a string to be manipulated
34
+     * @return the first 3 characters of `input`
35
+     */
36
+    public static String getPrefix(String input){
37
+        return null;
38
+    }
39
+
40
+    /**
41
+     * @param input a string to be manipulated
42
+     * @return the last 3 characters of `input`
43
+     */
44
+    public static String getSuffix(String input){
45
+        return null;
46
+    }
47
+
48
+    /**
49
+     * @param inputValue the value to be compared
50
+     * @param comparableValue the value to be compared against
51
+     * @return the equivalence of two strings, `inputValue` and `comparableValue`
52
+     */
53
+    public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
+        return null;
55
+    }
56
+
57
+    /**
58
+     * @param inputValue the value input from user
59
+     * @return the middle character of `inputValue`
60
+     */
61
+    public static Character getMiddleCharacter(String inputValue){
62
+        return null;
63
+    }
64
+
65
+    /**
66
+     * @param spaceDelimitedString a string, representative of a sentence, containing spaces
67
+     * @return the first sequence of characters
68
+     */
69
+    public static String getFirstWord(String spaceDelimitedString){
70
+        return null;
71
+    }
72
+
73
+    /**
74
+     * @param spaceDelimitedString a string delimited by spaces
75
+     * @return the second word of a string delimited by spaces.
76
+     */
77
+    public static String getSecondWord(String spaceDelimitedString){
78
+        return null;
79
+    }
80
+
81
+    /**
82
+     * @param stringToReverse
83
+     * @return an identical string with characters in reverse order.
84
+     */
85
+    public static String reverseTheTwo(String stringToReverse){
86
+        return null;
87
+    }
88
+}

+ 344
- 0
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestMathUtilities.java Voir le fichier

@@ -0,0 +1,344 @@
1
+package com.zipcodewilmington.danny_do_better_exercises;
2
+
3
+import org.junit.Test;
4
+
5
+import static org.junit.Assert.*;
6
+/**
7
+ * Created by dan on 6/14/17.
8
+ */
9
+public class TestMathUtilities {
10
+    private static volatile MathUtilities primativeTypes = new MathUtilities();
11
+
12
+    @Test
13
+    public void testAdditions() {
14
+        // : Given
15
+        int baseValue = 20;
16
+        int addedValue = 7;
17
+        int expected = 27;
18
+        // : When
19
+        int actual = primativeTypes.add(baseValue, addedValue);
20
+        // : Then
21
+        assertEquals(expected,actual);
22
+    }
23
+    @Test
24
+    public void testAdditions1() {
25
+        // : Given
26
+        long baseValue = 228437266;
27
+        long difference = 228437265;
28
+        long expected = 456874531;
29
+        // : When
30
+        long actual = primativeTypes.add(baseValue, difference);
31
+        // : Then
32
+        assertEquals(expected,actual);
33
+    }
34
+    @Test
35
+    public void testAdditions2() {
36
+        // : Given
37
+        short baseValue = 16384;
38
+        short addedValue = 7;
39
+        short expected = 32767;
40
+        // : When
41
+        short actual = primativeTypes.add(baseValue, addedValue);
42
+        // : Then
43
+        assertEquals(expected,actual);
44
+    }
45
+
46
+    @Test
47
+    public void testAdditions4() {
48
+        // : Given
49
+        byte baseValue = 63;
50
+        byte addedValue = 64;
51
+        byte expected = 127;
52
+        // : When
53
+        byte actual = primativeTypes.add(baseValue, addedValue);
54
+        // : Then
55
+        assertEquals(expected,actual);
56
+    }
57
+    @Test
58
+    public void testAdditions5() {
59
+        // : Given
60
+        float baseValue = 750.585F;
61
+        float addedValue = 795.000F;
62
+        float expected = 1545.585F;
63
+        // : When
64
+        float actual = primativeTypes.add(baseValue, addedValue);
65
+        // : Then
66
+        assertEquals(expected,actual, 0);
67
+    }
68
+
69
+    @Test
70
+    public void testAdditions6() {
71
+        // : Given
72
+        double baseValue = 225.25;
73
+        double addedValue = 231;
74
+        double expected = 456.25;
75
+        // : When
76
+        double actual = primativeTypes.add(baseValue,addedValue);
77
+        // : Then
78
+        assertEquals(expected,actual, 0);
79
+    }
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+    @Test
97
+    public void testSubtractions(){
98
+        // : Given
99
+        int baseValue = 20;
100
+        int difference = 7;
101
+        int expectedInt = 13;
102
+        // : When
103
+        int actualInt = primativeTypes.subtract(baseValue,difference);
104
+        // : Then
105
+        assertEquals(expectedInt,actualInt);
106
+    }
107
+    @Test
108
+    public void testSubtractions1() {
109
+        // : Given
110
+        long baseValue = 228437266;
111
+        long difference = 228437265;
112
+        long expectedLong = 1;
113
+        // : When
114
+        long actualLong = primativeTypes.subtract(baseValue, difference);
115
+        // : Then
116
+        assertEquals(expectedLong,actualLong);
117
+    }
118
+    @Test
119
+    public void testSubtractions2() {
120
+        // : Given
121
+        short baseValue = 16384;
122
+        short difference = 16383;
123
+        short expectedShort = 1;
124
+        // : When
125
+        short actualShort = primativeTypes.subtract(baseValue, difference);
126
+        // : Then
127
+        assertEquals(expectedShort,actualShort);
128
+    }
129
+    @Test
130
+    public void testSubtractions3() {
131
+        // : Given
132
+        byte baseValue = 63;
133
+        byte difference = 64;
134
+        byte expectedByte = -1;
135
+        // : When
136
+        byte actualByte = primativeTypes.subtract(baseValue, difference);
137
+        // : Then
138
+        assertEquals(expectedByte,actualByte);
139
+    }
140
+    @Test
141
+    public void testSubtractions4() {
142
+        // : Given
143
+        float baseValue = 750.585F;
144
+        float difference = 795.0F;
145
+        float expectedFloat = -44.415F;
146
+        // : When
147
+        float actualFloat = primativeTypes.subtract(baseValue,difference);
148
+        // : Then
149
+        assertEquals(expectedFloat,actualFloat, 0);
150
+    }
151
+    @Test
152
+    public void testSubtractions5() {
153
+        // : Given
154
+        double baseValue = 225.25;
155
+        double difference = 231;
156
+        double expectedDouble = -5.75;
157
+        // : When
158
+        double actualDouble = primativeTypes.subtract(baseValue, difference);
159
+        // : Then
160
+        assertEquals(expectedDouble,actualDouble, 0);
161
+    }
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+    @Test
177
+    public void testDivision(){
178
+        // : Given
179
+        int dividend = 20;
180
+        int divisor = 2;
181
+        int expectedInt = 10;
182
+        // : When
183
+        int actualInt = primativeTypes.divide(dividend, divisor);
184
+        // : Then
185
+        assertEquals(expectedInt,actualInt);
186
+    }
187
+    @Test
188
+    public void testDivision1() {
189
+        // : Given
190
+        int dividend = 20000000;
191
+        int divisor = 1000;
192
+        long expectedLong = 20000;
193
+        // : When
194
+        long actualLong = primativeTypes.divide(dividend, divisor);
195
+        // : Then
196
+        assertEquals(expectedLong,actualLong);
197
+    }
198
+    @Test
199
+    public void testDivision2() {
200
+        // : Given
201
+        short dividend = 2;
202
+        short divisor = 1;
203
+        short expectedShort = 2;
204
+        // : When
205
+        short actualShort = primativeTypes.divide(dividend, divisor);
206
+        // : Then
207
+        assertEquals(expectedShort,actualShort);
208
+
209
+    }
210
+    @Test
211
+    public void testDivision3() {
212
+        // : Given
213
+        byte dividend = 64;
214
+        byte divisor = 32;
215
+        byte expectedByte = 2;
216
+        // : When
217
+        byte actualByte = primativeTypes.divide(dividend, divisor);
218
+        // : Then
219
+        assertEquals(expectedByte,actualByte);
220
+    }
221
+    @Test
222
+    public void testDivision4() {
223
+        // : Given
224
+        float dividend = 7.5F;
225
+        float divisor = 3;
226
+        float expectedFloat = 2.50F;
227
+        // : When
228
+        float actualFloat = primativeTypes.divide(dividend,divisor);
229
+        // : Then
230
+        assertEquals(expectedFloat,actualFloat, 0);
231
+    }
232
+    @Test
233
+    public void testDivision5() {
234
+        // : Given
235
+        double dividend = 5.0;
236
+        double divisor = 4.0;
237
+        double expectedDouble = 1.25;
238
+        // : When
239
+        double actualDouble = primativeTypes.divide(dividend,divisor);
240
+        // : Then
241
+        assertEquals(expectedDouble,actualDouble, 0);
242
+    }
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+    @Test
262
+    public void testMultiplication(){
263
+        // : Given
264
+        int multiplicand = 5;
265
+        int multiplier = 2;
266
+        int expectedInt = 10;
267
+        // : When
268
+        int actualInt = primativeTypes.multiply(multiplicand,multiplier);
269
+        // : Then
270
+        assertEquals(expectedInt,actualInt);
271
+    }
272
+    @Test
273
+    public void testMultiplication1() {
274
+        // : Given
275
+        long multiplicand = 20;
276
+        long multiplier = 1000;
277
+        long expectedLong = 20000;
278
+        // : When
279
+        long actualLong = primativeTypes.multiply(multiplicand, multiplier);
280
+        // : Then
281
+        assertEquals(expectedLong, actualLong);
282
+    }
283
+    @Test
284
+    public void testMultiplication2() {
285
+        // : Given
286
+        short multiplicand = 2;
287
+        short multiplier = 1;
288
+        short expectedShort = 2;
289
+        // : When
290
+        short actualShort = primativeTypes.multiply(multiplicand, multiplier);
291
+        // : Then
292
+        assertEquals(expectedShort, actualShort);
293
+    }
294
+    @Test
295
+    public void testMultiplication3() {
296
+        // : Given
297
+        byte multiplicand = 16;
298
+        byte multiplier = 14;
299
+        byte expectedByte = 64;
300
+        // : When
301
+        byte actualByte = primativeTypes.multiply(multiplicand, multiplier);
302
+        // : Then
303
+        assertEquals(expectedByte, actualByte);
304
+    }
305
+    @Test
306
+    public void testMultiplication4() {
307
+        // : Given
308
+        float multiplicand = 2.5F;
309
+        float multiplier = 1;
310
+        float expectedFloat = 2.50F;
311
+        // : When
312
+        float actualFloat =  primativeTypes.multiply(multiplicand,multiplier);
313
+        // : Then
314
+        assertEquals(expectedFloat, actualFloat, 0);
315
+    }
316
+    @Test
317
+    public void testMultiplication5() {
318
+        // : Given
319
+        double multiplicand = 3.25;
320
+        double multiplier = 3.0;
321
+        double expectedDouble = 9.75;
322
+        // : When
323
+        double actualDouble = primativeTypes.multiply(multiplicand,multiplier);
324
+        // : Then
325
+        assertEquals(expectedDouble, actualDouble, 0);
326
+    }
327
+
328
+    @Test
329
+    public void testReturnTrue(){
330
+        // : Given
331
+        // : When
332
+        // : Then
333
+        assertTrue(primativeTypes.returnTrue());
334
+    }
335
+
336
+    @Test
337
+    public void testReturnFalse(){
338
+        // : Given
339
+        // : When
340
+        // : Then
341
+        assertFalse(primativeTypes.returnFalse());
342
+    }
343
+
344
+}

+ 121
- 0
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestPredicateUtilities.java Voir le fichier

@@ -0,0 +1,121 @@
1
+package com.zipcodewilmington.danny_do_better_exercises;
2
+
3
+import org.junit.Test;
4
+import static org.junit.Assert.*;
5
+/**
6
+ * Created by dan on 6/14/17.
7
+ */
8
+public class TestPredicateUtilities {
9
+    private static volatile PredicateUtilities math = new PredicateUtilities();
10
+
11
+    @Test
12
+    public void testGreaterThanTrue(){
13
+        // : Given
14
+        int greaterValue = 450;
15
+        int lesserValue = 350;
16
+
17
+
18
+        // : When
19
+        boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
20
+
21
+        // : Then
22
+        assertTrue(outcome);
23
+    }
24
+
25
+
26
+    @Test
27
+    public void testGreaterThanFalse(){
28
+        // : Given
29
+        int greaterValue = 350;
30
+        int lesserValue = 350;
31
+
32
+        // : When
33
+        boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
34
+
35
+        // : Then
36
+        assertTrue(outcome);
37
+    }
38
+
39
+
40
+    @Test
41
+    public void testLessThanTrue(){
42
+        // : Given
43
+        int greaterValue = 450;
44
+        int lesserValue = 350;
45
+
46
+        // : When
47
+        boolean outcome = math.isLessThan(greaterValue, lesserValue);
48
+
49
+        // : Then
50
+        assertFalse(outcome);
51
+    }
52
+
53
+
54
+
55
+    @Test
56
+    public void testLessThan1(){
57
+        // : Given
58
+        int greaterValue = 450;
59
+        int lesserValue = 350;
60
+
61
+        // : When
62
+        boolean outcome = math.isLessThan(greaterValue, lesserValue);
63
+
64
+        // : Then
65
+        assertTrue(outcome);
66
+    }
67
+
68
+
69
+    @Test
70
+    public void testLessOrEqual1(){
71
+        // : Given
72
+        int greaterValue = 3;
73
+        int lesserValue = 3;
74
+
75
+        // : When
76
+        boolean outcome = math.isLessThanOrEqualTo(greaterValue, lesserValue);
77
+
78
+        // : Then
79
+        assertTrue(outcome);
80
+    }
81
+
82
+    @Test
83
+    public void testLessOrEqual2(){
84
+        // : Given
85
+        int greaterValue = 3;
86
+        int lesserValue = 6;
87
+
88
+        // : When
89
+        boolean outcome = math.isLessThanOrEqualTo(greaterValue, lesserValue);
90
+
91
+        // : Then
92
+        assertTrue(outcome);
93
+    }
94
+
95
+    @Test
96
+    public void testGreaterOrEqual1(){
97
+        // : Given
98
+        int greaterValue = 4;
99
+        int lesserValue = 4;
100
+
101
+        // : When
102
+        boolean outcome = math.isGreaterThanOrEqualTo(greaterValue, lesserValue);
103
+
104
+        // : ThenP
105
+        assertTrue(outcome);
106
+    }
107
+
108
+
109
+    @Test
110
+    public void testGreaterOrEqual2(){
111
+        // : Given
112
+        int greaterValue = 8;
113
+        int lesserValue = 15;
114
+
115
+        // : When
116
+        boolean outcome = math.isGreaterThanOrEqualTo(greaterValue, lesserValue);
117
+
118
+        // : Then
119
+        assertTrue(outcome);
120
+    }
121
+}

+ 176
- 0
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.java Voir le fichier

@@ -0,0 +1,176 @@
1
+package com.zipcodewilmington.danny_do_better_exercises;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+import static org.junit.Assert.*;
6
+
7
+/**
8
+ * Created by dan on 6/14/17.
9
+ */
10
+public class TestStringUtilities {
11
+    @Test
12
+    public void getHelloWorldTest() {
13
+        // : Given
14
+        String expected = "Hello World";
15
+
16
+        // : When
17
+        String actual = StringUtilities.getHelloWorld();
18
+
19
+        // : Then
20
+        assertEquals(expected, actual);
21
+
22
+    }
23
+
24
+    @Test
25
+    public void concatenationStringTest(){
26
+        // : Given
27
+        String one = "Hello";
28
+        String two = " Java";
29
+        String expected = "Hello Java";
30
+
31
+        // : When
32
+        String actual = StringUtilities.concatenation(one,two);
33
+
34
+
35
+        // : Then
36
+        assertEquals(expected, actual);
37
+    }
38
+
39
+
40
+    @Test
41
+    public void concatenationStringAndIntegerTest(){
42
+        // : Given
43
+        int one = 1;
44
+        String two = " Java";
45
+        String expected = "1 Java";
46
+
47
+        // : When
48
+        String actual = StringUtilities.concatenation(one,two);
49
+
50
+
51
+        // : Then
52
+        assertEquals(expected, actual);
53
+    }
54
+
55
+    @Test
56
+    public void substringBeginTest(){
57
+        // : Given
58
+        String input = "Hello";
59
+        String expected = "olleH";
60
+
61
+        // : When
62
+        String actual = StringUtilities.getPrefix(input);
63
+
64
+        // : Then
65
+        assertEquals(expected, actual);
66
+    }
67
+
68
+    @Test
69
+    public void substringEndTest(){
70
+        // : Given
71
+        String input = "Hello";
72
+        String expected = "llo";
73
+
74
+        // : When
75
+        String actual = StringUtilities.getSuffix("Hello");
76
+
77
+        // : Then
78
+        assertEquals(expected, actual);
79
+    }
80
+
81
+    @Test
82
+    public void compareToTestEquals(){
83
+        // : Given
84
+        String inputValue = "Zipcode";
85
+        String comparableValue = "Zipcode";
86
+
87
+        // : When
88
+        boolean actual = StringUtilities.compareTwoStrings(inputValue, comparableValue);
89
+
90
+        // : Then
91
+        assertTrue(actual);
92
+    }
93
+
94
+
95
+    @Test
96
+    public void compareToTestNotEquals(){
97
+        // : Given
98
+        String inputValue = "Zipcode";
99
+        String comparableValue = "Zipcodee";
100
+
101
+        // : When
102
+        boolean actual = StringUtilities.compareTwoStrings(inputValue, comparableValue);
103
+
104
+        // : Then
105
+        assertFalse(actual);
106
+    }
107
+
108
+    @Test
109
+    public void getTheMiddleChar1(){
110
+        // : Given
111
+        String input = "Zipcode";
112
+        char expected = 'c';
113
+
114
+        // : When
115
+        char actual = StringUtilities.getMiddleCharacter(input);
116
+
117
+        // : Then
118
+        Assert.assertEquals(expected, actual);
119
+    }
120
+
121
+
122
+    @Test
123
+    public void getTheMiddleChar2(){
124
+        // : Given
125
+        String input = "Zipcoder";
126
+        Character expected = 'c';
127
+
128
+        // : When
129
+        Character actual = StringUtilities.getMiddleCharacter(input);
130
+
131
+        // : Then
132
+        Assert.assertEquals(expected.toString(), actual.toString());
133
+    }
134
+
135
+
136
+    @Test
137
+    public void getTheFirstWord(){
138
+        // : Given
139
+        String input = "Zipcode Wilmington";
140
+        String expected = "Zipcode";
141
+
142
+        // : When
143
+        String actual = StringUtilities.getFirstWord(input);
144
+
145
+        // : Then
146
+        assertEquals(expected, actual);
147
+    }
148
+
149
+
150
+    @Test
151
+    public void getTheSecondWord(){
152
+        // : Given
153
+        String input = "Zipcode Wilmington";
154
+        String expected = "Wilmington";
155
+
156
+        // : When
157
+        String actual = StringUtilities.getFirstWord(input);
158
+
159
+        // : Then
160
+        assertEquals(expected, actual);
161
+    }
162
+
163
+    @Test
164
+    public void reverseThem(){
165
+        // : Given
166
+        String input = "Zipcode Wilmington";
167
+        String expected = "notgnimliW edocpiZ";
168
+
169
+
170
+        // : When
171
+        String actual = StringUtilities.reverseTheTwo(input);
172
+
173
+        // : Then
174
+        assertEquals(expected, actual);
175
+    }
176
+}

+ 17
- 0
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestSuite.java Voir le fichier

@@ -0,0 +1,17 @@
1
+package com.zipcodewilmington.danny_do_better_exercises;
2
+
3
+import org.junit.runner.RunWith;
4
+import org.junit.runners.Suite;
5
+
6
+/**
7
+ * Created by leon on 2/5/18.
8
+ */
9
+@RunWith(Suite.class)
10
+
11
+@Suite.SuiteClasses({
12
+        TestPredicateUtilities.class,
13
+        TestMathUtilities.class,
14
+        TestStringUtilities.class,
15
+})
16
+public class TestSuite {
17
+}

BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.class Voir le fichier


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.class Voir le fichier


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class Voir le fichier


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestMathUtilities.class Voir le fichier


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestPredicateUtilities.class Voir le fichier


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.class Voir le fichier


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestSuite.class Voir le fichier