Carolynn Vansant il y a 6 ans
Parent
révision
f23c40cc2e

+ 5
- 6
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java Voir le fichier

1
 package com.zipcodewilmington.danny_do_better_exercises;
1
 package com.zipcodewilmington.danny_do_better_exercises;
2
 
2
 
3
-import static java.lang.System.*;
4
-
5
 /**
3
 /**
6
  * Created by dan on 6/14/17.
4
  * Created by dan on 6/14/17.
7
  */
5
  */
78
      * @return the first sequence of characters
76
      * @return the first sequence of characters
79
      */
77
      */
80
     public static String getFirstWord(String spaceDelimitedString){
78
     public static String getFirstWord(String spaceDelimitedString){
81
-
82
-        return null;
79
+        int spacer = spaceDelimitedString.indexOf(" ");
80
+        return spaceDelimitedString.substring(0, spacer);
83
     }
81
     }
84
 
82
 
85
     /**
83
     /**
87
      * @return the second word of a string delimited by spaces.
85
      * @return the second word of a string delimited by spaces.
88
      */
86
      */
89
     public static String getSecondWord(String spaceDelimitedString){
87
     public static String getSecondWord(String spaceDelimitedString){
90
-        return null;
88
+        int spacer = spaceDelimitedString.lastIndexOf(" ");
89
+        return spaceDelimitedString.substring(spacer);
91
     }
90
     }
92
 
91
 
93
     /**
92
     /**
95
      * @return an identical string with characters in reverse order.
94
      * @return an identical string with characters in reverse order.
96
      */
95
      */
97
     public static String reverseTheTwo(String stringToReverse){
96
     public static String reverseTheTwo(String stringToReverse){
98
-        return null;
97
+        return stringToReverse;
99
     }
98
     }
100
 }
99
 }

BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class Voir le fichier