Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/07_Delegation/01_delegationPattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ interface SoundBehavior {
fun makeSound()
}

class ScreamBehavior(val n:String): SoundBehavior { // 2
class ScreamBehavior(val n: String): SoundBehavior { // 2
override fun makeSound() = println("${n.uppercase()} !!!")
}

class RockAndRollBehavior(val n:String): SoundBehavior { // 2
class RockAndRollBehavior(val n: String): SoundBehavior { // 2
override fun makeSound() = println("I'm The King of Rock 'N' Roll: $n")
}

// Tom Araya is the "singer" of Slayer
class TomAraya(n:String): SoundBehavior by ScreamBehavior(n) // 3
class TomAraya(n: String): SoundBehavior by ScreamBehavior(n) // 3

// You should know ;)
class ElvisPresley(n:String): SoundBehavior by RockAndRollBehavior(n) // 3
class ElvisPresley(n: String): SoundBehavior by RockAndRollBehavior(n) // 3

fun main() {
val tomAraya = TomAraya("Thrash Metal")
Expand Down
Loading