Kaynağa Gözat

refactoring all of my labs and realized I never pushed the changes

Kaitrina High 6 yıl önce
ebeveyn
işleme
d430dd5ce5

+ 6
- 1
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java Dosyayı Görüntüle

@@ -66,7 +66,12 @@ public class StringUtilities {
66 66
      * @return the middle character of `inputValue`
67 67
      */
68 68
     public static Character getMiddleCharacter(String inputValue){
69
-        return inputValue.charAt(inputValue.length()/2 - 1);
69
+
70
+        if (inputValue.length() % 2 == 0){
71
+            return inputValue.charAt((inputValue.length()/2)-1);
72
+             }else {
73
+                return inputValue.charAt(inputValue.length()/2);
74
+                }
70 75
     }
71 76
 
72 77
     /**

BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class Dosyayı Görüntüle