Add more functions on money

This commit is contained in:
Sambo Chea 2020-08-26 21:19:31 +07:00
parent 315d2104c8
commit ad27257db7
2 changed files with 29 additions and 4 deletions

View File

@ -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()}')"
}
}

View File

@ -0,0 +1,6 @@
package com.cubetiqs.libra.moneyutils
interface StdMoneyFormation {
fun format(): String
fun toMoneyString(overrideSymbol: Char? = null): String
}