Compositional mystery of Red Circle

Report a typo

Look at the inheritance-based implementation of the RedCircle class and use the composition approach to implement the RedCircleComposition class.

Write a program in Kotlin
interface Color {
fun getColorCode(): String
}

interface Shape {
fun getShape(): String
fun countAngles(): Int
}

class RedCircle : Color, Shape {
override fun getColorCode(): String = "FF0000"
override fun getShape(): String = "Circle"
override fun countAngles(): Int = 0
}

object Red : Color {
override fun getColorCode(): String = "FF0000"
}

object Circle : Shape {
override fun getShape(): String = "Circle"
override fun countAngles(): Int = 0
}

// Do not change the code above.
// Change only *line* below.

class RedCircleComposition : // ?
___

Create a free account to access the full topic