Browse Source

doesn't matter

Owen Murphy 6 years ago
parent
commit
18bc2d26d0

+ 2
- 0
ChapterOneMicro.iml View File

12
     <orderEntry type="sourceFolder" forTests="false" />
12
     <orderEntry type="sourceFolder" forTests="false" />
13
     <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
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" />
14
     <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
15
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
16
+    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
15
   </component>
17
   </component>
16
 </module>
18
 </module>

+ 1
- 0
src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java View File

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
+
32
         return null;
33
         return null;
33
     }
34
     }
34
 
35
 

+ 4
- 4
src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java View File

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
+        return x > y;
14
     }
14
     }
15
 
15
 
16
     /**
16
     /**
19
      * @return true if `x` is less than `y`
19
      * @return true if `x` is less than `y`
20
      */
20
      */
21
     public Boolean isLessThan(int x, int y) {
21
     public Boolean isLessThan(int x, int y) {
22
-        return null;
22
+        return x <y;
23
     }
23
     }
24
 
24
 
25
     /**
25
     /**
28
      * @return true if `x` is greater than or equal to `y`
28
      * @return true if `x` is greater than or equal to `y`
29
      */
29
      */
30
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
30
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
-        return null;
31
+        return x >= y;
32
     }
32
     }
33
 
33
 
34
     /**
34
     /**
37
      * @return true if `x` is less than or equal to `y`
37
      * @return true if `x` is less than or equal to `y`
38
      */
38
      */
39
     public Boolean isLessThanOrEqualTo(int x, int y) {
39
     public Boolean isLessThanOrEqualTo(int x, int y) {
40
-        return null;
40
+        return x <= y;
41
     }
41
     }
42
 }
42
 }

+ 30
- 10
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java View File

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
+        return "Hello World";
12
     }
12
     }
13
 
13
 
14
     /**
14
     /**
17
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
17
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18
      */
18
      */
19
     public static String concatenation(String firstSegment, String secondSegment){
19
     public static String concatenation(String firstSegment, String secondSegment){
20
-        return null;
20
+        return firstSegment + secondSegment;
21
     }
21
     }
22
 
22
 
23
     /**
23
     /**
26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27
      */
27
      */
28
     public static String concatenation(int firstSegment, String secondSegment){
28
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
29
+
30
+        return firstSegment + secondSegment;
30
     }
31
     }
31
 
32
 
32
     /**
33
     /**
34
      * @return the first 3 characters of `input`
35
      * @return the first 3 characters of `input`
35
      */
36
      */
36
     public static String getPrefix(String input){
37
     public static String getPrefix(String input){
37
-        return null;
38
+       return input.substring(0, 3);
39
+
40
+
38
     }
41
     }
39
 
42
 
40
     /**
43
     /**
42
      * @return the last 3 characters of `input`
45
      * @return the last 3 characters of `input`
43
      */
46
      */
44
     public static String getSuffix(String input){
47
     public static String getSuffix(String input){
45
-        return null;
48
+        return input.substring(input.length() - 3);
49
+
46
     }
50
     }
47
 
51
 
48
     /**
52
     /**
51
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
55
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52
      */
56
      */
53
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
57
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
58
+        return (inputValue.equals(comparableValue)) ;
59
+
55
     }
60
     }
56
 
61
 
57
     /**
62
     /**
59
      * @return the middle character of `inputValue`
64
      * @return the middle character of `inputValue`
60
      */
65
      */
61
     public static Character getMiddleCharacter(String inputValue){
66
     public static Character getMiddleCharacter(String inputValue){
62
-        return null;
67
+        if (inputValue.length() % 2 == 1){
68
+            int bob = inputValue.length()/2;
69
+            return inputValue.charAt(bob);
70
+        }
71
+        else {
72
+            int bob = (inputValue.length() - 1)/2;
73
+            return inputValue.charAt(bob);
74
+        }
75
+
63
     }
76
     }
64
 
77
 
65
     /**
78
     /**
67
      * @return the first sequence of characters
80
      * @return the first sequence of characters
68
      */
81
      */
69
     public static String getFirstWord(String spaceDelimitedString){
82
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
83
+        String[] splitStr = spaceDelimitedString.trim().split("\\s+");
84
+                return splitStr[0];
85
+
71
     }
86
     }
72
 
87
 
73
     /**
88
     /**
75
      * @return the second word of a string delimited by spaces.
90
      * @return the second word of a string delimited by spaces.
76
      */
91
      */
77
     public static String getSecondWord(String spaceDelimitedString){
92
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
93
+        String[] splitStr = spaceDelimitedString.trim().split("\\s+");
94
+        return splitStr[1];
95
+
79
     }
96
     }
80
 
97
 
81
     /**
98
     /**
83
      * @return an identical string with characters in reverse order.
100
      * @return an identical string with characters in reverse order.
84
      */
101
      */
85
     public static String reverseTheTwo(String stringToReverse){
102
     public static String reverseTheTwo(String stringToReverse){
86
-        return null;
103
+        String bob = stringToReverse;
104
+        return new StringBuilder(bob).reverse().toString();
105
+
106
+
87
     }
107
     }
88
 }
108
 }

+ 3
- 3
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestPredicateUtilities.java View File

33
         boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
33
         boolean outcome = math.isGreaterThan(greaterValue, lesserValue);
34
 
34
 
35
         // : Then
35
         // : Then
36
-        assertTrue(outcome);
36
+        assertFalse(outcome);
37
     }
37
     }
38
 
38
 
39
 
39
 
62
         boolean outcome = math.isLessThan(greaterValue, lesserValue);
62
         boolean outcome = math.isLessThan(greaterValue, lesserValue);
63
 
63
 
64
         // : Then
64
         // : Then
65
-        assertTrue(outcome);
65
+        assertFalse(outcome);
66
     }
66
     }
67
 
67
 
68
 
68
 
116
         boolean outcome = math.isGreaterThanOrEqualTo(greaterValue, lesserValue);
116
         boolean outcome = math.isGreaterThanOrEqualTo(greaterValue, lesserValue);
117
 
117
 
118
         // : Then
118
         // : Then
119
-        assertTrue(outcome);
119
+        assertFalse(outcome);
120
     }
120
     }
121
 }
121
 }

+ 2
- 2
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.java View File

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 = "llo";
60
 
60
 
61
         // : When
61
         // : When
62
         String actual = StringUtilities.getPrefix(input);
62
         String actual = StringUtilities.getPrefix(input);
154
         String expected = "Wilmington";
154
         String expected = "Wilmington";
155
 
155
 
156
         // : When
156
         // : When
157
-        String actual = StringUtilities.getFirstWord(input);
157
+        String actual = StringUtilities.getSecondWord(input);
158
 
158
 
159
         // : Then
159
         // : Then
160
         assertEquals(expected, actual);
160
         assertEquals(expected, actual);

BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.class View File


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.class View File


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class View File


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestPredicateUtilities.class View File


BIN
target/test-classes/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.class View File