You're given a class HeavyBrickComposition, which is implemented using the composition approach. However, the implementations of the objects this class is composed of are missing, so your task is to complete them.
Interface composition
Heavy-looking brick
Report a typo
Write a program in Kotlin
interface Weight {
fun getWeight(): Int
fun affectedByGravity(): Boolean
}
interface Form {
fun getVolume(): Int
}
class HeavyBrick : Weight, Form {
override fun getWeight(): Int = 50
override fun affectedByGravity(): Boolean = true
override fun getVolume(): Int = 20
}
class HeavyBrickComposition : Weight by Heavy, Form by Brick
// Do not change the code above.
object // ?
object // ?
___
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.