Add more functions on money
This commit is contained in:
parent
315d2104c8
commit
ad27257db7
@ -1,7 +1,26 @@
|
||||
package com.cubetiqs.libra.moneyutils
|
||||
|
||||
data class Money(
|
||||
var value: Double,
|
||||
var currency: String = "USD"
|
||||
)
|
||||
open class Money(
|
||||
private var value: Double,
|
||||
private var currency: String = "USD"
|
||||
) : StdMoney {
|
||||
override fun getValue(): Double {
|
||||
return this.value
|
||||
}
|
||||
|
||||
fun setValue(value: Double) {
|
||||
this.value = value
|
||||
}
|
||||
|
||||
override fun getCurrency(): String {
|
||||
return this.currency.toUpperCase()
|
||||
}
|
||||
|
||||
fun setCurrency(currency: String) {
|
||||
this.currency = currency
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Money(value=${getValue()}, currency='${getCurrency()}')"
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package com.cubetiqs.libra.moneyutils
|
||||
|
||||
interface StdMoneyFormation {
|
||||
fun format(): String
|
||||
fun toMoneyString(overrideSymbol: Char? = null): String
|
||||
}
|
Loading…
Reference in New Issue
Block a user