Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Bonus {
- def apply(baseValue: float)(value: float) -> float
- def order: int
- }
- class PercentBonus(value: Int) extends Bonus {
- @override
- def apply(baseValue: float) -> baseValue * (1 + value / 100)
- def order = 10
- }
- def addBonus(bonus: Bonus) = bonuses.add(bonus)
- def getValue = bonuses.orderBy(_.order).fold(baseValue, (value, bonus) -> bonus.apply(value))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement