Created
June 14, 2021 02:29
-
-
Save CheolhoJeon/704f72b221a14a1a1b7d6f9457029823 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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