Last active
July 7, 2020 04:11
-
-
Save sasssass/f47cdfb3e63a6935f9378d74f630721f 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
// Object | |
interface Fruit{ | |
fun getName() : String | |
} | |
open class Orange : Fruit{ | |
override fun getName(): String = "Orange" | |
} | |
// Decorator | |
abstract class OrangeDecorator(var orange: Orange) : Orange(){ | |
} | |
class BloodyOrange(orange: Orange) : OrangeDecorator(orange){ | |
override fun getName(): String = orange.getName() + " Bloody" | |
} | |
class ThompsonOrange(orange: Orange) : OrangeDecorator(orange){ | |
override fun getName(): String = orange.getName() + " Thompson" | |
} | |
class BigOrange(orange: Orange) : OrangeDecorator(orange){ | |
override fun getName(): String = orange.getName() + " Big" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment