Groovy: Number guessing game
examples/groovy/number_guessing_game.groovy
Random random = new Random() def hidden = random.nextInt(20) while (true) { print "Guess number: " def guess = System.in.newReader().readLine() as Integer if (guess < hidden) { println "Guess was too small" } else if (guess > hidden) { println "Guess was too hight" } else { println "Match!" break } } println "Bye"
Published on 2018-05-27
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post