Kthomas 6 anni fa
parent
commit
aba185069b

+ 6
- 27
src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java Vedi File

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

+ 6
- 15
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java Vedi File

@@ -1,37 +1,31 @@
1 1
 package com.zipcodewilmington.danny_do_better_exercises;
2 2
 
3 3
 /**
4
- * Created by dan on 6/14/17.
4
+ * Refactored
5 5
  */
6 6
 public class StringUtilities {
7 7
 
8 8
     public static String getHelloWorld() {
9
-
10 9
         return "Hello World";
11 10
     }
12 11
 
13 12
     public static String concatenation(String firstSegment, String secondSegment){
14
-
15 13
         return firstSegment + secondSegment;
16 14
     }
17 15
 
18 16
     public static String concatenation(int firstSegment, String secondSegment){
19
-
20 17
         return firstSegment + secondSegment;
21 18
     }
22 19
 
23 20
     public static String getPrefix(String input){
24
-
25
-        return input.substring(0,3);
21
+        return input.substring(0,3); //returns a range of characters from the string from index positions 0 - 3 (prefix)
26 22
     }
27 23
 
28 24
     public static String getSuffix(String input){
29
-
30 25
         return input.substring(2);
31 26
     }
32 27
 
33 28
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
34
-
35 29
         return inputValue.equals(comparableValue) ;
36 30
     }
37 31
 
@@ -41,8 +35,8 @@ public class StringUtilities {
41 35
         if (middleIndex % 2 == 0){
42 36
             middleIndex = middleIndex - 1;
43 37
         }
44
-        char middleCharacter = inputValue.charAt(middleIndex);
45
-        return middleCharacter;
38
+
39
+        return inputValue.charAt(middleIndex);
46 40
     }
47 41
 
48 42
     public static String getFirstWord(String spaceDelimitedString) {
@@ -56,9 +50,6 @@ public class StringUtilities {
56 50
     }
57 51
 
58 52
     public static String reverseTheTwo(String stringToReverse){
59
-
60
-        String reverse = new StringBuffer(stringToReverse).reverse().toString();
61
-
62
-        return reverse;
53
+        return new StringBuffer(stringToReverse).reverse().toString();
63 54
     }
64
-}
55
+}

+ 2
- 3
src/main/java/com/zipcodewilmington/danny_do_better_exercises/ZipcodeRocks.java Vedi File

@@ -1,11 +1,10 @@
1 1
 package com.zipcodewilmington.danny_do_better_exercises;
2 2
 
3 3
 /**
4
- * Created by leon on 2/5/18.
4
+ * Refactored
5 5
  */
6 6
 public class ZipcodeRocks {
7 7
     public static void main(String[] args) {
8
-
9 8
         System.out.println("Zipcode Rocks!");
10 9
     }
11
-}
10
+}

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


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


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