mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 22:36:34 +01:00
Adding addition, subtraction and multiplication operations to CurrencyUnits
This commit is contained in:
parent
0be96f4188
commit
7bf2d3c6e2
1 changed files with 12 additions and 0 deletions
|
@ -29,6 +29,18 @@ abstract class CurrencyUnit(val value:Double) {
|
|||
def !=(c : CurrencyUnit) : Boolean = {
|
||||
!(this == c)
|
||||
}
|
||||
|
||||
def +(c : CurrencyUnit) : CurrencyUnit = {
|
||||
Satoshis(CurrencyUnits.toSatoshis(this).value + CurrencyUnits.toSatoshis(c).value)
|
||||
}
|
||||
|
||||
def -(c : CurrencyUnit) : CurrencyUnit = {
|
||||
Satoshis(CurrencyUnits.toSatoshis(this).value - CurrencyUnits.toSatoshis(c).value)
|
||||
}
|
||||
|
||||
def *(c : CurrencyUnit) : CurrencyUnit = {
|
||||
Satoshis(CurrencyUnits.toSatoshis(this).value * CurrencyUnits.toSatoshis(c).value)
|
||||
}
|
||||
}
|
||||
|
||||
case class Satoshis(override val value: Double) extends CurrencyUnit(value) {
|
||||
|
|
Loading…
Add table
Reference in a new issue