/* * ExchangeRateTable.java * * Created on: 27-Feb-2010 * */ package netukar.exchange; import java.util.LinkedHashMap; import java.util.Map; /** * * The exchange rate values are referred to Euro. * * The exchange rate values were taken from http://www.kb.cz/NASA/rateList/SRVRate * 27-Feb-2010. * * * @author radovan */ public class ExchangeRateTable { private static final ExchangeRateTable instance = new ExchangeRateTable(); public static ExchangeRateTable getInstance() { return instance; } private Map table; /** * Creates a new instance of ExchangeRateTable. */ private ExchangeRateTable() { table = new LinkedHashMap(); table.put(Currency.EUR, 1.0); table.put(Currency.CZK, 25.376); table.put(Currency.SEK, 9.2176); table.put(Currency.NOK, 7.6572); table.put(Currency.USD, 1.3027); table.put(Currency.JPY, 114.3578); } public double getExchangeRate(Currency in, Currency out) { double referredCurrencyRate = 1 / table.get(in); return referredCurrencyRate * table.get(out); } public Currency[] getAvailableCurrencies() { return table.keySet().toArray(new Currency[0]); } }