Skip to content

Instantly share code, notes, and snippets.

@techtide
Created October 5, 2018 10:34
Show Gist options
  • Save techtide/2042fd4f143d2ff8cec6472f1d0de8b5 to your computer and use it in GitHub Desktop.
Save techtide/2042fd4f143d2ff8cec6472f1d0de8b5 to your computer and use it in GitHub Desktop.
/**
* A class that makes song lyrics for Shirley Ellis'
* hit single, "The Name Game".
* Author(s): Arman, Fletcher
* Date: 03/10/2018
*/
public class NameGame {
private String name;
public NameGame(String name) {
this.name = name;
}
public static void main(String[] args) {
NameGame kent = new NameGame("Kent");
String lyrics = kent.buildSong();
System.out.println(lyrics);
// BONUS: use args[0] as the source of the name
}
private String buildVerseB() {
if(name.substring(0, 1) == "B") {
String boVerse1 = "Bo-" + name.substring(1);
return name +", " + name + ", " + boVerse1;
} else {
String boVerse = "Bo-b" + name.substring(1);
String verse = name + ", " + name + ", " + boVerse;
return verse;
}
}
private String buildVerseF() {
if(name.substring(0, 1) == "F") {
String foVerse1 = "Fo-" + name.substring(1);
return name +", " + name + ", " + foVerse1;
} else {
String verse = "Bonana-fanna fo-f" + name.substring(1);
return verse;
}
}
private String buildVerseM() {
if(name.substring(0, 1) == "M") {
String moVerse1 = "Mo-" + name.substring(2);
return name +", " + name + ", " + moVerse1;
} else {
String verse = "Fee fi mo-m" + name.substring(1);
return verse;
}
}
public String buildSong() {
String song = "Let's do "+name+ "!\n";
song = song + buildVerseB()+ "\n" + buildVerseF() + "\n" + buildVerseM() + "\n";
song = song + name+"!";
return song;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment