/** Class with static methods for handling strings */
public class CallStack {
    
    /** 
     * Yields: copy of s but in the form <last-name>, <first-name>  
     * Precondition: s is in the form <first-name> <last-name>  
     *               with one or more blanks between the two names 
     */
    public static String lastNameFirst(String s) {
        System.out.println("Create frame for lastNameFirst");
        String first = firstName(s);
        String last  = lastName(s);
        System.out.println("Erase frame for lastNameFirst");
        return last+", "+first;
    }
    
    /**
     * Yields: First name in s
     * Precondition: s is in the form <first-name> <last-name>  
     *               with one or more blanks between the two names 
     */
    public static String firstName(String s) {
        System.out.println("Create frame for firstName");
        int endOfFirst = s.indexOf(" ");
        System.out.println("Erase frame for firstName");
        return s.substring(0,endOfFirst);
    }

    /**
     * Yields: Last name in s
     * Precondition: s is in the form <first-name> <last-name>  
     *               with one or more blanks between the two names 
     */
    public static String lastName(String s) {
        System.out.println("Create frame for lastName");
        int startOfLast = s.lastIndexOf(" ");
        System.out.println("Erase frame for lastName");
        return s.substring(startOfLast+1);
    }

}