1234567891011121314151617181920
  1. public class CurrencyConverter {
  2. public Currency baseCurrency;
  3. public CurrencyConverter(Currency defaultBaseCurrency){
  4. this.baseCurrency = defaultBaseCurrency;
  5. }
  6. public void setBaseCurrency(Currency newBaseCurrency){
  7. this.baseCurrency = newBaseCurrency;
  8. }
  9. public Currency getBaseCurrency(Currency currentCurrency){
  10. return this.baseCurrency;
  11. }
  12. public double convert(Double amount, Currency quoteCurrency){
  13. return amount * (1/this.baseCurrency.getRate()) * (quoteCurrency.getRate());
  14. }
  15. }