Inheritance and Interfaces
Interfaces
Implement a small interface with a class.
Interfaces
Interfaces.kt
interface Describable {
fun describe(): String
}
class Task(val title: String) : Describable {
override fun describe(): String {
return "task:$title"
}
}
fun main() {
val title =
val task = Task(title)
val description = task.describe()
println("title=$title")
println("description=$description")
}
interface Describable {
fun describe(): String
}
class Task(val title: String) : Describable {
override fun describe(): String {
return "task:$title"
}
}
fun main() {
val title =
val task = Task(title)
val description = task.describe()
println("title=$title")
println("description=$description")
}
interface Describable {
fun describe(): String
}
class Task(val title: String) : Describable {
override fun describe(): String {
return "task:$title"
}
}
fun main() {
val title =
val task = Task(title)
val description = task.describe()
println("title=$title")
println("description=$description")
}
interface
An interface names behavior that a class promises to provide.