Heavy-looking brick

Report a typo

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.

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 // ?
___

Create a free account to access the full topic