Getting rid of copy-pasting: constructing an interface

Report a typo

Suppose you're working with a set of classes as follows:

class Triangle {
    val angles: Int = 3
    val scale: Double = 1.0

    fun draw() {
        /* ... */
    }
}

class Rectangle {
    val angles: Int = 4
    val scale: Double  = 1.0

    fun draw() {
        /* ... */
    }
}

class Hexagon {
    val angles: Int = 6
    val scale: Double = 1.0

    fun draw() {
        /* ... */
    }
}

As you can see, these classes have a few things in common, so it would be convenient in terms of optimizing the code if all of them were implementations of a certain interface.

Introduce an interface so that any of the above classes could be implementations of this interface.

Write a program in Kotlin
interface Shape {
// Your code here
}
___

Create a free account to access the full topic