/** ThemBonesSong.java computes the lyrics of "Them Bones..."
 *  @author Joel Adams
 *
 */

public class ThemBonesSong {
    private String myLyrics = null;
    private String [] myBones = { "head", "neck", "shoulder",
				  "back", "hip", "thigh", "knee",
				  "leg", "ankle", "foot", "toe" };

    public ThemBonesSong() {
	myLyrics = firstPart();
	myLyrics += middlePart(myBones.length - 1);
	myLyrics += lastPart();
    }

    private String firstPart() {
	return "Ezekiel cried, \"Them dry bones!\"\n"
	    +  "Ezekiel cried, \"Them dry bones!\"\n"
	    +  "Ezekiel cried, \"Them dry bones!\"\n"
	    +  "Now hear the word of the Lord!\n\n";
    }

    private String middlePart(int i) {
	if (i > 0) {
		String winding = "The " + myBones[i]
				+ "-bone  connected to the "
				+ myBones[i-1] + "-bone\n";
		String middle = middlePart(i-1);
		String unwinding = "The " + myBones[i-1]
				+ "-bone  connected to the "
				+ myBones[i] + "-bone\n";
		return winding + middle + unwinding;
	} else {
		return lastPart() + "\n";
	}
    }

    private String lastPart() {
	return "Now hear the word of the Lord!\n"
		+ "\nThem bones them bones gonna walk around.\n"
		+ "Them bones them bones gonna walk around.\n"
		+ "Them bones them bones gonna walk around.\n"
		+ "Now hear the word of the Lord!\n";
    }

    public String toString() {
	return myLyrics;
    }

    public static void main(String [] args) {
	System.out.println( new ThemBonesSong() );
    }
}

