Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
35
Task/The-Name-Game/Java/the-name-game.java
Normal file
35
Task/The-Name-Game/Java/the-name-game.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import java.util.stream.Stream;
|
||||
|
||||
public class NameGame {
|
||||
private static void printVerse(String name) {
|
||||
StringBuilder sb = new StringBuilder(name.toLowerCase());
|
||||
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
|
||||
String x = sb.toString();
|
||||
String y = "AEIOU".indexOf(x.charAt(0)) > -1 ? x.toLowerCase() : x.substring(1);
|
||||
String b = "b" + y;
|
||||
String f = "f" + y;
|
||||
String m = "m" + y;
|
||||
switch (x.charAt(0)) {
|
||||
case 'B':
|
||||
b = y;
|
||||
break;
|
||||
case 'F':
|
||||
f = y;
|
||||
break;
|
||||
case 'M':
|
||||
m = y;
|
||||
break;
|
||||
default:
|
||||
// no adjustment needed
|
||||
break;
|
||||
}
|
||||
System.out.printf("%s, %s, bo-%s\n", x, x, b);
|
||||
System.out.printf("Banana-fana fo-%s\n", f);
|
||||
System.out.printf("Fee-fi-mo-%s\n", m);
|
||||
System.out.printf("%s!\n\n", x);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Stream.of("Gary", "Earl", "Billy", "Felix", "Mary", "Steve").forEach(NameGame::printVerse);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue