Skip to content

Instantly share code, notes, and snippets.

@CheolhoJeon
Created June 14, 2021 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CheolhoJeon/704f72b221a14a1a1b7d6f9457029823 to your computer and use it in GitHub Desktop.
Save CheolhoJeon/704f72b221a14a1a1b7d6f9457029823 to your computer and use it in GitHub Desktop.
package chap5.Object
import atomictest.eq
open class Paint(val color: String) {
open fun apply() = "Applying $color"
}
object Acrylic: Paint("Blue") {
override fun apply() = "Acrylic, ${super.apply()}"
}
interface PaintPreparation {
fun prepare(): String
}
object Prepare: PaintPreparation {
override fun prepare() = "Scrape"
}
fun main() {
Prepare.prepare() eq "Scrape"
Paint("Green").apply() eq "Applying Green"
Acrylic.apply() eq "Acrylic, Applying Blue"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment