if/else Statements
For the purposes of your bounty board, the player’s strength is determined by their playerLevel, which you created in the previous chapter. Lower values indicate that the hero is closer to the beginning of their epic journey, and higher values indicate that a hero has gained experience and has become stronger.
Your goal is to present quests based on the player’s current level. For example, if a player is at level 1 (the starting point for new characters), then they need to be given an easy quest, like a tutorial.
Within the main function, write your first if/else
statement, as shown below.
We will break down this new code after you enter it.
Listing 3.1 Printing the player’s quest (Main.kt
)
const val HERO_NAME ...
Get Kotlin Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.