Katrice Williams-Dredden před 6 roky
rodič
revize
11a8f75ec2

+ 10
- 4
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java Zobrazit soubor

@@ -1,5 +1,6 @@
1 1
 package com.zipcodewilmington.danny_do_better_exercises;
2 2
 
3
+
3 4
 /**
4 5
  * Created by dan on 6/14/17.
5 6
  */
@@ -100,10 +101,15 @@ public class StringUtilities {
100 101
      */
101 102
     public static String reverseTheTwo(String stringToReverse){
102 103
         //so if the string contains a space, I want to split it then reverse it
103
-        if (stringToReverse.contains(" ")
104
-            return(reverse(stringToReverse.split(" ")));
105
-        else //if not still reverse it
106
-            return(reverse(stringToReverse));
104
+        StringBuilder sb = new StringBuilder(stringToReverse);
105
+        return sb.reverse().toString();
106
+
107
+
108
+//        if (stringToReverse.contains(" "){
109
+//            return(reverse(stringToReverse.split(" ")));
110
+//        }else{ //if not still reverse it
111
+//            return(reverse(stringToReverse));
112
+//        }
107 113
     }
108 114
 }
109 115
 

+ 4
- 4
src/test/java/com/zipcodewilmington/danny_do_better_exercises/TestStringUtilities.java Zobrazit soubor

@@ -109,13 +109,13 @@ public class TestStringUtilities {
109 109
     public void getTheMiddleChar1(){
110 110
         // : Given
111 111
         String input = "Zipcode";
112
-        char expected = 'c';
112
+        Character expected = 'c';
113 113
 
114 114
         // : When
115
-        int actual = StringUtilities.getMiddleCharacter(input);
115
+        Character actual = StringUtilities.getMiddleCharacter(input);
116 116
 
117 117
         // : Then
118
-        Assert.assertEquals(expected, actual);
118
+        Assert.assertEquals(expected.toString(), actual.toString());
119 119
     }
120 120
 
121 121
 
@@ -126,7 +126,7 @@ public class TestStringUtilities {
126 126
         Character expected = 'c';
127 127
 
128 128
         // : When
129
-        char actual = StringUtilities.getMiddleCharacter(input);
129
+        Character actual = StringUtilities.getMiddleCharacter(input);
130 130
 
131 131
         // : Then
132 132
         Assert.assertEquals(expected.toString(), actual.toString());

binární
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class Zobrazit soubor