Introduced CoinType for transfer between different currencies
parent
bc960ddf37
commit
6c4fef6cc1
@ -0,0 +1,34 @@
|
|||||||
|
package de.banananetwork.dsa.currencies;
|
||||||
|
|
||||||
|
public enum CoinType {
|
||||||
|
// TODO Transfer from constant values to variable ones
|
||||||
|
// TODO Add some other currencies (https://de.wiki-aventurica.de/wiki/Aventurische_W%C3%A4hrungen)
|
||||||
|
MITTELREICH_KREUZER(1), // Base Value
|
||||||
|
MITTELREICH_NICKEL(2),
|
||||||
|
MITTELREICH_HELLER(10),
|
||||||
|
MITTELREICH_SILBERTALER(MITTELREICH_HELLER, 10),
|
||||||
|
MITTELREICH_DUKATEN(MITTELREICH_SILBERTALER, 10);
|
||||||
|
|
||||||
|
private final int multiplier;
|
||||||
|
|
||||||
|
CoinType(int multiplier) {
|
||||||
|
this.multiplier = multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoinType(CoinType reference, int multiplier) {
|
||||||
|
this.multiplier = reference.multiplier * multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int transferTo(int baseValue) {
|
||||||
|
return baseValue / multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double transferToExact(int baseValue) {
|
||||||
|
return (double) baseValue / multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int transferFrom(int coinValue) {
|
||||||
|
return coinValue * multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue