Created
February 5, 2023 09:47
-
-
Save alibahaaa/9eb78a353074dd97228a66aabe8852e2 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
interface Component { | |
fun operation() | |
} | |
class ConcreteComponent : Component { | |
override fun operation() { | |
// implementation | |
} | |
} | |
abstract class Decorator(private val component: Component) : Component { | |
override fun operation() { | |
component.operation() | |
} | |
} | |
class ConcreteDecoratorA(component: Component) : Decorator(component) { | |
override fun operation() { | |
super.operation() | |
// additional behavior | |
} | |
} | |
class ConcreteDecoratorB(component: Component) : Decorator(component) { | |
override fun operation() { | |
super.operation() | |
// additional behavior | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment