You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
921 B
Java
39 lines
921 B
Java
package de.banananetwork.dsa.currencies;
|
|
|
|
public enum Currency {
|
|
// 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;
|
|
|
|
Currency(int multiplier) {
|
|
this.multiplier = multiplier;
|
|
}
|
|
|
|
Currency(Currency 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;
|
|
}
|
|
|
|
public int getMultiplier() {
|
|
return multiplier;
|
|
}
|
|
|
|
}
|