Created
July 13, 2018 02:40
-
-
Save esirK/ae60d8dc834b2788dd6224989a4e92fa 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
abstract class CondimentDecorator: Beverage() { | |
abstract override var description: String | |
} | |
class Soya(var beverage: Beverage): CondimentDecorator() { | |
override fun cost(): Double { | |
return beverage.cost() + 1.0 | |
} | |
override var description = beverage.description + ", Soy" | |
} | |
class Mocha(var beverage: Beverage) : CondimentDecorator() { | |
override var description = beverage.description + ", Mocha" | |
override fun cost(): Double { | |
return beverage.cost() + 0.5 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment