Skip to content

Commit

Permalink
test(samples): add new samples
Browse files Browse the repository at this point in the history
kotlin-samples-pusher-bot committed Jan 13, 2025

Verified

This commit was signed with the committer’s verified signature.
TimothyWillard Timothy Willard
1 parent ee61caf commit df7d892
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -2,19 +2,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")

0 comments on commit df7d892

Please sign in to comment.