1234567891011121314151617181920 |
- public class CurrencyConverter {
- public Currency baseCurrency;
-
- public CurrencyConverter(Currency defaultBaseCurrency){
- this.baseCurrency = defaultBaseCurrency;
- }
-
- public void setBaseCurrency(Currency newBaseCurrency){
- this.baseCurrency = newBaseCurrency;
- }
-
- public Currency getBaseCurrency(Currency currentCurrency){
- return this.baseCurrency;
- }
-
- public double convert(Double amount, Currency quoteCurrency){
- return amount * (1/this.baseCurrency.getRate()) * (quoteCurrency.getRate());
- }
- }
|