Advertisement
wandrake

Untitled

Oct 27th, 2013
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.80 KB | None | 0 0
  1. import java.util.Random
  2.  
  3. object JappoApp extends App {
  4.     val random = new Random(System.currentTimeMillis())
  5.     val hiragana = Map(
  6.         "あ" -> "a",
  7.         "い" -> "i",
  8.         "う" -> "u",
  9.         "え" -> "e",
  10.         "お" -> "o",
  11.         "か" -> "ka",
  12.         "き" -> "ki",
  13.         "く" -> "ku",
  14.         "け" -> "ke",
  15.         "こ" -> "ko",
  16.         "さ" -> "sa",
  17.         "し" -> "shi",
  18.         "す" -> "su",
  19.         "せ" -> "se",
  20.         "そ" -> "so"
  21.     )
  22.  
  23.     def f(): Int = {
  24.         val q = hiragana.keySet.toArray
  25.         val k = q(random.nextInt(q.length))
  26.         println(k)
  27.         val s = readLine()
  28.  
  29.         if (s == hiragana(k)) println("OK")
  30.         else if (s == ".") return 0
  31.         else println("Wrong")
  32.  
  33.         return f()
  34.     }
  35.  
  36.     f()
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement