Our new intern created two similar objects inside our Player class. Let's help the intern merge both objects into one companion object.
Computer scienceProgramming languagesKotlinObject-oriented programmingSpecial constructions / Special classes
Companion object
Companion
Report a typo
Write a program in Kotlin
class Player(val id: Int, val name: String, val speed: Int, val health: Int, val armor: Int) {
object BaseProperties {
val baseSpeed = 7
val baseHealth = 100
val baseArmor = 100
}
object MaxProperties {
val maxSpeed = 13
val maxHealth = 140
val maxArmor = 100
}
}
___
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.