kotlin override some functions code example
Example: kotlin override
open class Shape {
open val vertexCount: Int = 0
open fun draw() { /*...*/ }
fun fill() { /*...*/ }
}
class Rectangle() : Shape() {
override fun draw() { /*...*/ } // overrides method
override val vertexCount = 4 // overrides property, can be set later
}
class Losange(override val vertexCount: Int = 4) : Shape
// Always has 4 vertices, can't be set later