// Die.kt class Die() { fun roll(): Int { return (1..6).random() } } // Main.kt fun main() { println("Welcome to the Die Roller Application!") val die = Die() do { println("Rolling the die...") val result = die.roll() println("You rolled a $result!") println("Do you want to roll again? (yes/no)") val input = readLine()?.trim()?.lowercase() } while (input == "yes") println("Thanks for using the Die Roller Application!") }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter