|
@@ -11,69 +11,42 @@ public class StringUtilities {
|
11
|
11
|
return ayMane;
|
12
|
12
|
}
|
13
|
13
|
|
14
|
|
- /**
|
15
|
|
- * @param firstSegment a string to be added to
|
16
|
|
- * @param secondSegment a string to add
|
17
|
|
- * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
|
18
|
|
- */
|
19
|
14
|
public static String concatenation(String firstSegment, String secondSegment){
|
20
|
|
- return null;
|
|
15
|
+ String newWordConcat = firstSegment + secondSegment;
|
|
16
|
+ return newWordConcat;
|
21
|
17
|
}
|
22
|
18
|
|
23
|
|
- /**
|
24
|
|
- * @param firstSegment a string to be added to
|
25
|
|
- * @param secondSegment a string to add
|
26
|
|
- * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
|
27
|
|
- */
|
28
|
19
|
public static String concatenation(int firstSegment, String secondSegment){
|
29
|
|
- return null;
|
|
20
|
+ String firstSegmentToString = Integer.toString(firstSegment);
|
|
21
|
+ return firstSegmentToString + secondSegment;
|
30
|
22
|
}
|
31
|
23
|
|
32
|
|
- /**
|
33
|
|
- * @param input a string to be manipulated
|
34
|
|
- * @return the first 3 characters of `input`
|
35
|
|
- */
|
36
|
24
|
public static String getPrefix(String input){
|
37
|
|
- return null;
|
|
25
|
+ return input.substring(0, 3);
|
38
|
26
|
}
|
39
|
27
|
|
40
|
|
- /**
|
41
|
|
- * @param input a string to be manipulated
|
42
|
|
- * @return the last 3 characters of `input`
|
43
|
|
- */
|
44
|
28
|
public static String getSuffix(String input){
|
45
|
|
- return null;
|
|
29
|
+ String stepOne = new StringBuilder(input).reverse().toString();
|
|
30
|
+ String stepTwo = stepOne.substring(0, 3);
|
|
31
|
+ return new StringBuilder(stepTwo).reverse().toString();
|
46
|
32
|
}
|
47
|
33
|
|
48
|
|
- /**
|
49
|
|
- * @param inputValue the value to be compared
|
50
|
|
- * @param comparableValue the value to be compared against
|
51
|
|
- * @return the equivalence of two strings, `inputValue` and `comparableValue`
|
52
|
|
- */
|
53
|
34
|
public static Boolean compareTwoStrings(String inputValue, String comparableValue){
|
54
|
|
- return null;
|
|
35
|
+ return new String(inputValue).equals(comparableValue);
|
55
|
36
|
}
|
56
|
37
|
|
57
|
|
- /**
|
58
|
|
- * @param inputValue the value input from user
|
59
|
|
- * @return the middle character of `inputValue`
|
60
|
|
- */
|
61
|
38
|
public static Character getMiddleCharacter(String inputValue){
|
62
|
|
- return null;
|
|
39
|
+ String hadToReverseItBecauseOneOfTheDamnTestCasesWouldntWork = new StringBuilder(inputValue).reverse().toString();
|
|
40
|
+ int length = (hadToReverseItBecauseOneOfTheDamnTestCasesWouldntWork.length())/2;
|
|
41
|
+ char middleChild[] = hadToReverseItBecauseOneOfTheDamnTestCasesWouldntWork.toCharArray();
|
|
42
|
+ return middleChild[length];
|
63
|
43
|
}
|
64
|
44
|
|
65
|
|
- /**
|
66
|
|
- * @param spaceDelimitedString a string, representative of a sentence, containing spaces
|
67
|
|
- * @return the first sequence of characters
|
68
|
|
- */
|
69
|
45
|
public static String getFirstWord(String spaceDelimitedString){
|
70
|
|
- return null;
|
|
46
|
+ String[] probablyZipcode = spaceDelimitedString.split("\\s+");
|
|
47
|
+ return probablyZipcode[0];
|
71
|
48
|
}
|
72
|
49
|
|
73
|
|
- /**
|
74
|
|
- * @param spaceDelimitedString a string delimited by spaces
|
75
|
|
- * @return the second word of a string delimited by spaces.
|
76
|
|
- */
|
77
|
50
|
public static String getSecondWord(String spaceDelimitedString){
|
78
|
51
|
String[] probablyWilmington = spaceDelimitedString.split("\\s+");
|
79
|
52
|
return probablyWilmington[1];
|