Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/The-Name-Game/Scala/the-name-game.scala
Normal file
21
Task/The-Name-Game/Scala/the-name-game.scala
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
object NameGame extends App {
|
||||
private def printVerse(name: String): Unit = {
|
||||
val x = name.toLowerCase.capitalize
|
||||
|
||||
val y = if ("AEIOU" contains x.head) x.toLowerCase else x.tail
|
||||
|
||||
val (b, f, m) = x.head match {
|
||||
case 'B' => (y, "f" + y, "m" + y)
|
||||
case 'F' => ("b" + y, y, "m" + y)
|
||||
case 'M' => ("b" + y, "f" + y, y)
|
||||
case _ => ("b" + y, "f" + y, "m" + y)
|
||||
}
|
||||
|
||||
printf("%s, %s, bo-%s\n", x, x, b)
|
||||
printf("Banana-fana fo-%s\n", f)
|
||||
println(s"Fee-fi-mo-$m")
|
||||
println(s"$x!\n")
|
||||
}
|
||||
|
||||
Stream("gAry", "earl", "Billy", "Felix", "Mary", "Steve").foreach(printVerse)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue