Created
September 21, 2018 15:18
-
-
Save kioba/195af9a6d8a16af5ac1ad9e242f2a5fa to your computer and use it in GitHub Desktop.
Sample code for architecture challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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