defaultcurrencyconverter.java

来自「一些很有用的spring的书籍」· Java 代码 · 共 19 行

JAVA
19
字号
package com.apress.springbook.chapter10;

public class DefaultCurrencyConverter implements CurrencyConverter {
  private ExchangeRateService exchangeRateService;

  public void setExchangeRateService(ExchangeRateService exchangeRateService) {
    this.exchangeRateService = exchangeRateService;
  }

  public double convert(double amount, String fromCurrency, String toCurrency)
   throws UnknownCurrencyException {
    // get the currect exchange rate for the specified currencies
    double exchangeRate = 
      exchangeRateService.getExchangeRate(fromCurrency, toCurrency);
    // return the amount multiplied with the exchange rate
    return amount * exchangeRate;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?