Joshua Wurdemann 6 vuotta sitten
vanhempi
commit
9afb066640

+ 1
- 1
.idea/compiler.xml Näytä tiedosto

@@ -9,7 +9,7 @@
9 9
         <module name="ChapterOneMicro" />
10 10
       </profile>
11 11
     </annotationProcessing>
12
-    <bytecodeTargetLevel target="1.8">
12
+    <bytecodeTargetLevel>
13 13
       <module name="ChapterOneMicro" target="1.8" />
14 14
     </bytecodeTargetLevel>
15 15
   </component>

+ 0
- 7
.idea/kotlinc.xml Näytä tiedosto

@@ -1,7 +0,0 @@
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>

+ 1
- 78
.idea/misc.xml Näytä tiedosto

@@ -7,84 +7,7 @@
7 7
       </list>
8 8
     </option>
9 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 10
   <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>
11
+    <output url="file://$PROJECT_DIR$/out" />
89 12
   </component>
90 13
 </project>

+ 37
- 25
src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java Näytä tiedosto

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

+ 22
- 4
src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java Näytä tiedosto

@@ -10,7 +10,12 @@ public class PredicateUtilities {
10 10
      * @return true if `x` is greater than `y`
11 11
      */
12 12
     public Boolean isGreaterThan(int x, int y) {
13
-        return null;
13
+        boolean great = false;
14
+        if (x > y) {
15
+            great = true;
16
+        }
17
+
18
+        return great;
14 19
     }
15 20
 
16 21
     /**
@@ -19,7 +24,11 @@ public class PredicateUtilities {
19 24
      * @return true if `x` is less than `y`
20 25
      */
21 26
     public Boolean isLessThan(int x, int y) {
22
-        return null;
27
+        boolean good = false;
28
+        if (x < y) {
29
+            good = true;
30
+        }
31
+        return good;
23 32
     }
24 33
 
25 34
     /**
@@ -28,7 +37,11 @@ public class PredicateUtilities {
28 37
      * @return true if `x` is greater than or equal to `y`
29 38
      */
30 39
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
-        return null;
40
+        boolean great = false;
41
+        if (x >= y) {
42
+            great = true;
43
+        }
44
+        return great;
32 45
     }
33 46
 
34 47
     /**
@@ -37,6 +50,11 @@ public class PredicateUtilities {
37 50
      * @return true if `x` is less than or equal to `y`
38 51
      */
39 52
     public Boolean isLessThanOrEqualTo(int x, int y) {
40
-        return null;
53
+
54
+        boolean great = false;
55
+        if (x <= y) {
56
+            great = true;
57
+        }
58
+        return great;
41 59
     }
42 60
 }

+ 47
- 16
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java Näytä tiedosto

@@ -8,7 +8,8 @@ public class StringUtilities {
8 8
      * @return `Hello World` as a string
9 9
      */
10 10
     public static String getHelloWorld() {
11
-        return null;
11
+        String hello = "Hello World";
12
+        return hello;
12 13
     }
13 14
 
14 15
     /**
@@ -17,7 +18,8 @@ public class StringUtilities {
17 18
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18 19
      */
19 20
     public static String concatenation(String firstSegment, String secondSegment){
20
-        return null;
21
+
22
+        return firstSegment + secondSegment;
21 23
     }
22 24
 
23 25
     /**
@@ -25,8 +27,12 @@ public class StringUtilities {
25 27
      * @param secondSegment a string to add
26 28
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27 29
      */
28
-    public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
30
+    public static String concatenation(int firstSegment, String secondSegment) {
31
+//    String firstString = Integer.toString(firstSegment);
32
+       // firstSegment = "a string to be added to";
33
+
34
+
35
+        return String.valueOf(firstSegment) + secondSegment;
30 36
     }
31 37
 
32 38
     /**
@@ -34,7 +40,9 @@ public class StringUtilities {
34 40
      * @return the first 3 characters of `input`
35 41
      */
36 42
     public static String getPrefix(String input){
37
-        return null;
43
+
44
+
45
+        return input.substring(0,3);
38 46
     }
39 47
 
40 48
     /**
@@ -42,7 +50,8 @@ public class StringUtilities {
42 50
      * @return the last 3 characters of `input`
43 51
      */
44 52
     public static String getSuffix(String input){
45
-        return null;
53
+        String shortString = input.substring(input.length() -3);
54
+        return shortString;
46 55
     }
47 56
 
48 57
     /**
@@ -50,24 +59,41 @@ public class StringUtilities {
50 59
      * @param comparableValue the value to be compared against
51 60
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52 61
      */
53
-    public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
55
-    }
62
+    public static Boolean compareTwoStrings(String inputValue, String comparableValue) {
56 63
 
57
-    /**
64
+
65
+        return inputValue.equals(comparableValue);
66
+
67
+
68
+    }
69
+        /**
58 70
      * @param inputValue the value input from user
59 71
      * @return the middle character of `inputValue`
60 72
      */
61
-    public static Character getMiddleCharacter(String inputValue){
62
-        return null;
63
-    }
73
+    public static Character getMiddleCharacter(String inputValue) {
74
+
75
+
76
+        //return  middleString = inputValue.charAt(inputValue.length()/2);
77
+ // even length string
78
+        //if (inputValue.length() % 2 == 0) {
79
+            char middleString = inputValue.charAt(inputValue.length() / 2);
64 80
 
81
+           // return middleString;
82
+        //} else
83
+            return middleString;
84
+    }
65 85
     /**
66 86
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
67 87
      * @return the first sequence of characters
68 88
      */
69 89
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
90
+       // String [] firstWord;
91
+        //
92
+       // how can I get rid of regex or why would I use regex?
93
+        // firstWord = spaceDelimitedString.split("");
94
+
95
+       // return firstWord[0];
96
+        return spaceDelimitedString.substring(0,spaceDelimitedString.indexOf(""));
71 97
     }
72 98
 
73 99
     /**
@@ -75,7 +101,8 @@ public class StringUtilities {
75 101
      * @return the second word of a string delimited by spaces.
76 102
      */
77 103
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
104
+
105
+        return spaceDelimitedString.substring(spaceDelimitedString.indexOf(""),spaceDelimitedString.length());
79 106
     }
80 107
 
81 108
     /**
@@ -83,6 +110,10 @@ public class StringUtilities {
83 110
      * @return an identical string with characters in reverse order.
84 111
      */
85 112
     public static String reverseTheTwo(String stringToReverse){
86
-        return null;
113
+         StringBuilder reverseString = new StringBuilder();
114
+        reverseString.append(stringToReverse);
115
+        reverseString = reverseString.reverse();
116
+       return reverseString.toString();
117
+
87 118
     }
88 119
 }

+ 1
- 1
src/main/java/com/zipcodewilmington/danny_do_better_exercises/ZipcodeRocks.java Näytä tiedosto

@@ -5,6 +5,6 @@ package com.zipcodewilmington.danny_do_better_exercises;
5 5
  */
6 6
 public class ZipcodeRocks {
7 7
     public static void main(String[] args) {
8
-//         System.out.println("Zipcode Rocks!");
8
+       System.out.println("Zipcode Rocks!");
9 9
     }
10 10
 }

+ 1
- 1
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestMathUtilities.java Näytä tiedosto

@@ -36,7 +36,7 @@ public class TestMathUtilities {
36 36
         // : Given
37 37
         short baseValue = 16384;
38 38
         short addedValue = 7;
39
-        short expected = 32767;
39
+        short expected = 16391;
40 40
         // : When
41 41
         short actual = primativeTypes.add(baseValue, addedValue);
42 42
         // : Then

+ 2
- 2
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.java Näytä tiedosto

@@ -56,7 +56,7 @@ public class TestStringUtilities {
56 56
     public void substringBeginTest(){
57 57
         // : Given
58 58
         String input = "Hello";
59
-        String expected = "olleH";
59
+        String expected = "Hel";
60 60
 
61 61
         // : When
62 62
         String actual = StringUtilities.getPrefix(input);
@@ -129,7 +129,7 @@ public class TestStringUtilities {
129 129
         Character actual = StringUtilities.getMiddleCharacter(input);
130 130
 
131 131
         // : Then
132
-        Assert.assertEquals(expected.toString(), actual.toString());
132
+        Assert.assertEquals(expected, actual);
133 133
     }
134 134
 
135 135
 

BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.class Näytä tiedosto


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.class Näytä tiedosto


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class Näytä tiedosto


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/ZipcodeRocks.class Näytä tiedosto


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestMathUtilities.class Näytä tiedosto


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.class Näytä tiedosto