Joshua Wurdemann 6 лет назад
Родитель
Сommit
9afb066640

+ 1
- 1
.idea/compiler.xml Просмотреть файл

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

+ 0
- 7
.idea/kotlinc.xml Просмотреть файл

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 Просмотреть файл

7
       </list>
7
       </list>
8
     </option>
8
     </option>
9
   </component>
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">
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
   </component>
12
   </component>
90
 </project>
13
 </project>

+ 37
- 25
src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java Просмотреть файл

11
      * @return sum of `baseValue` and `difference`
11
      * @return sum of `baseValue` and `difference`
12
      */
12
      */
13
     public Integer add(int baseValue, int difference) {
13
     public Integer add(int baseValue, int difference) {
14
-        return null;
14
+        return baseValue + difference;
15
     }
15
     }
16
 
16
 
17
     /**
17
     /**
20
      * @return sum of `baseValue` and `difference`
20
      * @return sum of `baseValue` and `difference`
21
      */
21
      */
22
     public Long add(long baseValue, long difference) {
22
     public Long add(long baseValue, long difference) {
23
-        return null;
23
+        return baseValue + difference;
24
     }
24
     }
25
 
25
 
26
     /**
26
     /**
29
      * @return sum of `baseValue` and `difference`
29
      * @return sum of `baseValue` and `difference`
30
      */
30
      */
31
     public Short add(short baseValue, short difference) {
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
      * @return sum of `baseValue` and `difference`
40
      * @return sum of `baseValue` and `difference`
39
      */
41
      */
40
     public Byte add(byte baseValue, byte difference) {
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
      * @return sum of `baseValue` and `difference`
50
      * @return sum of `baseValue` and `difference`
48
      */
51
      */
49
     public Float add(float baseValue, float difference) {
52
     public Float add(float baseValue, float difference) {
50
-        return null;
53
+        return baseValue + difference;
51
     }
54
     }
52
 
55
 
53
     /**
56
     /**
56
      * @return sum of `baseValue` and `difference`
59
      * @return sum of `baseValue` and `difference`
57
      */
60
      */
58
     public Double add(double baseValue, double difference) {
61
     public Double add(double baseValue, double difference) {
59
-        return null;
62
+        return baseValue + difference;
60
     }
63
     }
61
 
64
 
62
     /**
65
     /**
65
      * @return difference between `baseValue` and `difference`
68
      * @return difference between `baseValue` and `difference`
66
      */
69
      */
67
     public Integer subtract(int baseValue, int difference) {
70
     public Integer subtract(int baseValue, int difference) {
68
-        return null;
71
+        return baseValue - difference;
69
     }
72
     }
70
 
73
 
71
     /**
74
     /**
74
      * @return difference between `baseValue` and `difference`
77
      * @return difference between `baseValue` and `difference`
75
      */
78
      */
76
     public Long subtract(long baseValue, long difference) {
79
     public Long subtract(long baseValue, long difference) {
77
-        return null;
80
+        return baseValue - difference;
78
     }
81
     }
79
 
82
 
80
     /**
83
     /**
83
      * @return difference between `baseValue` and `difference`
86
      * @return difference between `baseValue` and `difference`
84
      */
87
      */
85
     public Short subtract(short baseValue, short difference) {
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
      * @return difference between `baseValue` and `difference`
96
      * @return difference between `baseValue` and `difference`
93
      */
97
      */
94
     public Byte subtract(byte baseValue, byte difference) {
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
      * @return difference between `baseValue` and `difference`
108
      * @return difference between `baseValue` and `difference`
102
      */
109
      */
103
     public Float subtract(float baseValue, float difference) {
110
     public Float subtract(float baseValue, float difference) {
104
-        return null;
111
+        return baseValue - difference;
105
     }
112
     }
106
 
113
 
107
     /**
114
     /**
110
      * @return difference between `baseValue` and `difference`
117
      * @return difference between `baseValue` and `difference`
111
      */
118
      */
112
     public Double subtract(double baseValue, double difference) {
119
     public Double subtract(double baseValue, double difference) {
113
-        return null;
120
+        return baseValue - difference;
114
     }
121
     }
115
 
122
 
116
 
123
 
120
      * @return division of `dividend` by `divisor
127
      * @return division of `dividend` by `divisor
121
      */
128
      */
122
     public Integer divide(int dividend, int divisor) {
129
     public Integer divide(int dividend, int divisor) {
123
-        return null;
130
+        return dividend / divisor;
124
     }
131
     }
125
 
132
 
126
     /**
133
     /**
129
      * @return division of `dividend` by `divisor
136
      * @return division of `dividend` by `divisor
130
      */
137
      */
131
     public Long divide(long dividend, long divisor) {
138
     public Long divide(long dividend, long divisor) {
132
-        return null;
139
+        return dividend / divisor;
133
     }
140
     }
134
 
141
 
135
     /**
142
     /**
138
      * @return division of `dividend` by `divisor
145
      * @return division of `dividend` by `divisor
139
      */
146
      */
140
     public Short divide(short dividend, short divisor) {
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
      * @return division of `dividend` by `divisor
155
      * @return division of `dividend` by `divisor
148
      */
156
      */
149
     public Byte divide(byte dividend, byte divisor) {
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
      * @return division of `dividend` by `divisor
165
      * @return division of `dividend` by `divisor
157
      */
166
      */
158
     public Float divide(float dividend, float divisor) {
167
     public Float divide(float dividend, float divisor) {
159
-        return null;
168
+        return dividend / divisor;
160
     }
169
     }
161
 
170
 
162
     /**
171
     /**
165
      * @return division of `dividend` by `divisor
174
      * @return division of `dividend` by `divisor
166
      */
175
      */
167
     public Double divide(double dividend, double divisor) {
176
     public Double divide(double dividend, double divisor) {
168
-        return null;
177
+        return  dividend / divisor;
169
     }
178
     }
170
 
179
 
171
 
180
 
175
      * @return product of `multiplicand` by `multiplier`
184
      * @return product of `multiplicand` by `multiplier`
176
      */
185
      */
177
     public Integer multiply(int multiplicand, int multiplier) {
186
     public Integer multiply(int multiplicand, int multiplier) {
178
-        return null;
187
+        return multiplicand * multiplier;
179
     }
188
     }
180
 
189
 
181
     /**
190
     /**
184
      * @return product of `multiplicand` by `multiplier`
193
      * @return product of `multiplicand` by `multiplier`
185
      */
194
      */
186
     public Long multiply(long multiplicand, long multiplier) {
195
     public Long multiply(long multiplicand, long multiplier) {
187
-        return null;
196
+        return multiplicand * multiplier;
188
     }
197
     }
189
 
198
 
190
     /**
199
     /**
193
      * @return product of `multiplicand` by `multiplier`
202
      * @return product of `multiplicand` by `multiplier`
194
      */
203
      */
195
     public Short multiply(short multiplicand, short multiplier) {
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
      * @param multiplicand value to be multiplied
209
      * @param multiplicand value to be multiplied
201
      * @return product of `multiplicand` by `multiplier`
211
      * @return product of `multiplicand` by `multiplier`
202
      */
212
      */
203
     public Byte multiply(byte multiplicand, byte multiplier) {
213
     public Byte multiply(byte multiplicand, byte multiplier) {
214
+        byte product = (byte) (multiplicand * multiplier);
215
+
204
         return null;
216
         return null;
205
     }
217
     }
206
 
218
 
210
      * @return product of `multiplicand` by `multiplier`
222
      * @return product of `multiplicand` by `multiplier`
211
      */
223
      */
212
     public Float multiply(float multiplicand, float multiplier) {
224
     public Float multiply(float multiplicand, float multiplier) {
213
-        return null;
225
+        return multiplicand * multiplier;
214
     }
226
     }
215
 
227
 
216
     /**
228
     /**
219
      * @return product of `multiplicand` by `multiplier`
231
      * @return product of `multiplicand` by `multiplier`
220
      */
232
      */
221
     public Double multiply(double multiplicand, double multiplier) {
233
     public Double multiply(double multiplicand, double multiplier) {
222
-        return null;
234
+        return  multiplicand * multiplier;
223
     }
235
     }
224
 
236
 
225
 
237
 
227
       * @return true
239
       * @return true
228
      */
240
      */
229
     public Boolean returnTrue() {
241
     public Boolean returnTrue() {
230
-        return null;
242
+        return true;
231
     }
243
     }
232
 
244
 
233
     /**
245
     /**
234
      * @return false
246
      * @return false
235
      */
247
      */
236
     public Boolean returnFalse() {
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 Просмотреть файл

10
      * @return true if `x` is greater than `y`
10
      * @return true if `x` is greater than `y`
11
      */
11
      */
12
     public Boolean isGreaterThan(int x, int y) {
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
      * @return true if `x` is less than `y`
24
      * @return true if `x` is less than `y`
20
      */
25
      */
21
     public Boolean isLessThan(int x, int y) {
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
      * @return true if `x` is greater than or equal to `y`
37
      * @return true if `x` is greater than or equal to `y`
29
      */
38
      */
30
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
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
      * @return true if `x` is less than or equal to `y`
50
      * @return true if `x` is less than or equal to `y`
38
      */
51
      */
39
     public Boolean isLessThanOrEqualTo(int x, int y) {
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 Просмотреть файл

8
      * @return `Hello World` as a string
8
      * @return `Hello World` as a string
9
      */
9
      */
10
     public static String getHelloWorld() {
10
     public static String getHelloWorld() {
11
-        return null;
11
+        String hello = "Hello World";
12
+        return hello;
12
     }
13
     }
13
 
14
 
14
     /**
15
     /**
17
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18
      */
19
      */
19
     public static String concatenation(String firstSegment, String secondSegment){
20
     public static String concatenation(String firstSegment, String secondSegment){
20
-        return null;
21
+
22
+        return firstSegment + secondSegment;
21
     }
23
     }
22
 
24
 
23
     /**
25
     /**
25
      * @param secondSegment a string to add
27
      * @param secondSegment a string to add
26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
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
      * @return the first 3 characters of `input`
40
      * @return the first 3 characters of `input`
35
      */
41
      */
36
     public static String getPrefix(String input){
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
      * @return the last 3 characters of `input`
50
      * @return the last 3 characters of `input`
43
      */
51
      */
44
     public static String getSuffix(String input){
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
      * @param comparableValue the value to be compared against
59
      * @param comparableValue the value to be compared against
51
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
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
      * @param inputValue the value input from user
70
      * @param inputValue the value input from user
59
      * @return the middle character of `inputValue`
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
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
86
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
67
      * @return the first sequence of characters
87
      * @return the first sequence of characters
68
      */
88
      */
69
     public static String getFirstWord(String spaceDelimitedString){
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
      * @return the second word of a string delimited by spaces.
101
      * @return the second word of a string delimited by spaces.
76
      */
102
      */
77
     public static String getSecondWord(String spaceDelimitedString){
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
      * @return an identical string with characters in reverse order.
110
      * @return an identical string with characters in reverse order.
84
      */
111
      */
85
     public static String reverseTheTwo(String stringToReverse){
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 Просмотреть файл

5
  */
5
  */
6
 public class ZipcodeRocks {
6
 public class ZipcodeRocks {
7
     public static void main(String[] args) {
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 Просмотреть файл

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

+ 2
- 2
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.java Просмотреть файл

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

Двоичные данные
target/classes/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.class Просмотреть файл


Двоичные данные
target/classes/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.class Просмотреть файл


Двоичные данные
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class Просмотреть файл


Двоичные данные
target/classes/com/zipcodewilmington/danny_do_better_exercises/ZipcodeRocks.class Просмотреть файл


Двоичные данные
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestMathUtilities.class Просмотреть файл


Двоичные данные
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.class Просмотреть файл