You want to create a function getPlayerInfo() that receives a player and returns information using the getInfo() function. However, the Player class code contains an error. You need to find it, fix the problem, and complete the function.
Computer scienceProgramming languagesKotlinObject-oriented programmingSpecial constructions / Special classes
Companion object
Fix an error
Report a typo
Write a program in Kotlin
class Player(val id: Int, val name: String) {
companion object {
var role = "playable character"
fun getInfo() = "$id, $name, $role"
}
}
fun getPlayerInfo(player: Player) = // TODO
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.