Skip to content

Instantly share code, notes, and snippets.

@kioba
Created September 21, 2018 15:18
Show Gist options
  • Save kioba/195af9a6d8a16af5ac1ad9e242f2a5fa to your computer and use it in GitHub Desktop.
Save kioba/195af9a6d8a16af5ac1ad9e242f2a5fa to your computer and use it in GitHub Desktop.
Sample code for architecture challenge
fun main(args: Array<String>) {
println("what is your name?")
val name = readLine()
println("Hello $name welcome to the ArrowGame!")
var exec = true
while (exec) {
val num = Random().nextInt(5) + 1
println("Dear $name, please guess a number from 1 to 5:")
val guess = readLine()!!.toInt()
if (guess == num) println("You guessed right $name!")
else println("You guessed wrong, $name! The number was: $num")
println("Do you want to continue $name?")
when (readLine()) {
"y" -> exec = true
"n" -> exec = false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment