This code contains an error. Find it and fix the problem!
Note: the error can be fixed in more than one way.
Computer scienceProgramming languagesKotlinObject-oriented programmingSpecial constructions / Special classes
Companion object
Fix me
Report a typo
Write a program in Kotlin
class Player(val id: Int, name: String) {
companion object {
val defaultSpeed = 8
val maxSpeed = 13
fun calcMovePenalty(cell: Int): Int {
return defaultSpeed - cell % 3
}
}
}
fun calculatePlayerSpeed(cell: Int): Int {
return Player.Properties.calcMovePenalty(cell)
}
___
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.