public class Test4C extends Object
Modifier and Type | Method and Description |
---|---|
static String |
doubler(String s)
Returns the string formed by repeating each character in
the specified string.
|
static String |
flipCase(String s)
Returns a string where the case of each letter is flipped compared to the
corresponding letter in s.
|
static void |
repair(List<Integer> t)
Sorts the elements of the list t so that the elements are
in ascending order.
|
static int |
wheresWaldo(Waldo waldo,
int locA,
int locB)
Returns the location of Waldo given two guesses of Waldo's location.
|
public static String doubler(String s)
doubler("") returns the string equal to "" doubler("a") returns the string equal to "aa" doubler("xy") returns the string equal to "xxyy" doubler("big") returns the string equal to "bbiigg" doubler("EECS") returns the string equal to "EEEECCSS"
s
- a stringpublic static String flipCase(String s)
flipCase("") returns the string equal to "" flipCase("a") returns the string equal to "A" flipCase("A") returns the string equal to "a" flipCase("abCd") returns the string equal to "ABcD" flipCase("CAMELcASE") returns the string equal to "camelCase"
s
- a string consisting of English letter characterspublic static void repair(List<Integer> t)
[1, 0] 1, 0 is out of order [0, 2, 1] 2, 1 is out of order [0, 2, 1, 3] 2, 1 is out of order [0, 2, 1, 4, 3] 2, 1 and 4, 3 are out of order [0, 1, 3, 2, 4] 3, 2 is out of order
This method switches the positions of the out-of-order adjacent elements thus repairing the list so that it is in sorted order.
t
- a list of almost sorted elementspublic static int wheresWaldo(Waldo waldo, int locA, int locB)
This method can find Waldo's location using 32 or fewer recursive calls (i.e., it does not check every possible location for Waldo).
waldo
- a reference to a Waldo objectlocA
- a guess of Waldo's locationlocB
- a guess of Waldo's location