October 2021
Intermediate to advanced
500 pages
16h 23m
English
Your strings are formatted and include the hero’s name, so it is time to move on to your next task. So far, Madrigal’s skill level has been hardcoded into your application. It can only be changed by modifying your code and recompiling the program. This means that players will always be given the same quest unless they recompile their own game. Not ideal.
To address this shortcoming, you will need to read user input from the console. Update your main function with a call to readLine, which will do just that.
Listing 6.6 Reading text from the console (Main.kt)
...
fun main() {
println("$HERO_NAME announces her presence to the world.")
println("What level is $HERO_NAME?")
val input = readLine()
println("$HERO_NAME's ...Read now
Unlock full access