/** Class with static methods for handling strings */ public class ReorderString { /** * Yields: copy of s but in the form , * Precondition: s is in the form * with one or more blanks between the two names */ public static String lastNameFirst(String s) { int endOfFirst = s.indexOf(" "); String firstName = s.substring(0,endOfFirst); // Find the first name // Find the last name // Put them together with a comma return firstName; // Stub return } /** * Yields: copy of s but in the form , * Precondition: s is in the form * with one or more blanks between the two names */ public static String lastNameFirst2(String s) { String first = firstName(s); String last = lastName(s); return last+", "+first; } /** * Yields: First name in s * Precondition: s is in the form * with one or more blanks between the two names */ public static String firstName(String s) { int endOfFirst = s.indexOf(" "); return s.substring(0,endOfFirst); } /** * Yields: Last name in s * Precondition: s is in the form * with one or more blanks between the two names */ public static String lastName(String s) { return ""; // Stub return } }