Stefan Beyer
08/21/2019, 11:37 AMabstract class BaseGreeter(val salutation: String) {
fun greet(name: String) = println("$salutation, $name!")
}
class HelloGreeter: BaseGreeter("Hello") {
// class specific stuff here
}
class HiGreeter: BaseGreeter("Hi") {
// class specific stuff here
}
class AhoiGreeter: BaseGreeter("Ahoi") {
// class specific stuff here
}
fun main() {
AhoiGreeter().greet("Kotlin")
}
into this:
abstract class BaseGreeter {
abstract val salutation: String
fun greet(name: String) = println("$salutation, $name!")
}
class HelloGreeter: BaseGreeter() {
override val salutation = "Hello"
// class specific stuff here
}
class HiGreeter: BaseGreeter() {
override val salutation = "Hi"
// class specific stuff here
}
class AhoiGreeter: BaseGreeter() {
override val salutation = "Ahoi"
// class specific stuff here
}
fun main() {
AhoiGreeter().greet("Kotlin")
}
I have some refactoring to do and this is a task that would probably take me half a day if I have to do this all manually ^^Mike
08/21/2019, 11:51 AMMike
08/21/2019, 11:56 AMStefan Beyer
08/21/2019, 1:58 PMMike
08/21/2019, 2:39 PM