Last active
May 16, 2017 12:37
-
-
Save wispborne/2b8b433a03b9a136b4943571254caf85 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Barker : NoiseMaker { | |
override fun makeSound() { | |
println("Bark!") | |
} | |
} |
This file contains hidden or 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
class Dog : NoiseMaker { | |
private val barker = Barker() | |
override fun makeSound() { | |
// Delegate to the Barker class instead of implementing it here | |
barker.makeSound() | |
} | |
} |
This file contains hidden or 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
interface NoiseMaker { | |
fun makeSound() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment