StringThing.java
/* 
    this program will do some character string processing 
 */

package stringthing;

public class StringThing {
    public static void main(String[] args){
        //point A: create and print some strings that represent names
        String singer = "Holiday, Billie";
        String sculptor = "Claudel, Camille";
        String painter = "Picasso, Pablo";
        String dancer = "Zotto, Osvaldo";
        String self = "Whyte, Caleb";

        System.out.println("\nNames...");
        System.out.println(singer);
        System.out.println(sculptor);
        System.out.println(painter);
        System.out.println(dancer);
        System.out.println(self);

        //point B: compute and print the lengths of the strings, w/out labels
        int singerLength = singer.length();
        int sculptorLength = sculptor.length();
        int painterLength = painter.length();
        int dancerLength = dancer.length();
        int selfLength = self.length();

        System.out.println("\nName Lengths...");
        System.out.println(singerLength);
        System.out.println(sculptorLength);
        System.out.println(painterLength);
        System.out.println(dancerLength);
        System.out.println(selfLength);

        //point C: compute and print the location of the comma w/in each string, no labels
        int singerCommaPosition = singer.indexOf(",");
        int sculptorCommaPosition = sculptor.indexOf(",");
        int painterCommaPosition = painter.indexOf(",");
        int dancerCommaPosition = dancer.indexOf(",");
        int selfCommaPosition = self.indexOf(",");

        System.out.println("\nComma Positions...");
        System.out.println(singerCommaPosition);
        System.out.println(sculptorCommaPosition);
        System.out.println(painterCommaPosition);
        System.out.println(dancerCommaPosition);
        System.out.println(selfCommaPosition);

        //point D: compute and print the five first names, no labels
        String singerFirst = singer.substring(9,15);
        String sculptorFirst = sculptor.substring(9,16);
        String painterFirst = painter.substring(9,14);
        String dancerFirst = dancer.substring(7,14);
        String selfFirst = self.substring(7,12);

        System.out.println("\nFirst Names...");
        System.out.println(singerFirst);
        System.out.println(sculptorFirst);
        System.out.println(painterFirst);
        System.out.println(dancerFirst);
        System.out.println(selfFirst);

        //point E: compute and print the five last names, no labels
        String singerLast = singer.substring(0,7);
        String sculptorLast = sculptor.substring(0,7);
        String painterLast = painter.substring(0,7);
        String dancerLast = dancer.substring(0,5);
        String selfLast = self.substring(0,5);

        System.out.println("\nLast Names...");
        System.out.println(singerLast);
        System.out.println(sculptorLast);
        System.out.println(painterLast);
        System.out.println(dancerLast);
        System.out.println(selfLast);

        //point F: compute and print the first names, again
        System.out.println("\nFirst Names, once again...");
        System.out.println(firstName(singer));
        System.out.println(firstName(sculptor));
        System.out.println(firstName(painter));
        System.out.println(firstName(dancer));
        System.out.println(firstName(self));

        //point G: compute and print the last names, again
        System.out.println("\nLast names, once again...");
        System.out.println(lastName(singer));
        System.out.println(lastName(sculptor));
        System.out.println(lastName(painter));
        System.out.println(lastName(dancer));
        System.out.println(lastName(self));

        //point H: compute and print the full names, natural style
        System.out.println("\nFull names, natural style...");
        System.out.println(fullName(singer));
        System.out.println(fullName(sculptor));
        System.out.println(fullName(painter));
        System.out.println(fullName(dancer));
        System.out.println(fullName(self));
    }


    private static String firstName(String directoryStyleName) {
        int nameStart = directoryStyleName.indexOf(",");
        String firstName = directoryStyleName.substring(nameStart + 2);
        return firstName;
    }

    private static String lastName(String directoryStyleName) {
        int lastEnd = directoryStyleName.indexOf(",");
        String lastName = directoryStyleName.substring(0,lastEnd);
        return lastName;
    }

    private static String fullName(String directoryStyleName){
        int nameStart = directoryStyleName.indexOf(",");
        String firstName = directoryStyleName.substring(nameStart + 2);
        int lastEnd = directoryStyleName.indexOf(",");
        String lastName = directoryStyleName.substring(0,lastEnd);
        String gap = " ";
        return firstName + gap + lastName;
    }

}