task3/solution13/src/org/apidesign/apifest08/currency/Convertor.java
changeset 58 07c16ec15a25
parent 45 251d0ed461fb
     1.1 --- a/task3/solution13/src/org/apidesign/apifest08/currency/Convertor.java	Tue Oct 07 11:05:34 2008 +0200
     1.2 +++ b/task3/solution13/src/org/apidesign/apifest08/currency/Convertor.java	Fri Oct 10 22:24:52 2008 +0200
     1.3 @@ -8,8 +8,12 @@
     1.4   * <p>
     1.5   * Conversion method are:
     1.6   * <ul>
     1.7 - * <li>{@link #convert(ConvertorCurrency, ConvertorCurrency, BigDecimal)} - convert using exchange rate specified in exchange rate provide. <em>Do not try use reverted excahnage rate</em>. 
     1.8 - * <li>{@link #convertWithReversibleRates(ConvertorCurrency, ConvertorCurrency, BigDecimal)} - convert using exchange rate specified in exchange rate provide. <em>Try use reverted excahnage rate</em>. 
     1.9 + * <li>{@link #convert(ConvertorCurrency, ConvertorCurrency, BigDecimal)} - convert
    1.10 + * using exchange rate specified in exchange rate provide. This method is not try 
    1.11 + * use reverted excahnage rate. 
    1.12 + * <li>{@link #convertWithReversibleRates(ConvertorCurrency, ConvertorCurrency, BigDecimal)} - 
    1.13 + * convert using exchange rate specified in exchange rate provide. This method
    1.14 + * is not trying to use reverted exchange rate.
    1.15   * </ul>
    1.16   * 
    1.17   * Exchange rate is provided by {@link ExchangeRateProvider}.
    1.18 @@ -130,7 +134,7 @@
    1.19              to = rate.getToValue();
    1.20          }
    1.21  
    1.22 -        BigDecimal amountCent = amount.movePointRight(2);
    1.23 +        BigDecimal amountCent = amount.movePointRight(toFractionDigits);
    1.24  
    1.25          final BigDecimal multiplied = amountCent.multiply(to, context);
    1.26          BigDecimal[] division = multiplied.divideAndRemainder(from, context);
    1.27 @@ -141,7 +145,8 @@
    1.28              result.setRemainder(BigDecimal.ZERO);
    1.29          }
    1.30  
    1.31 -        final BigDecimal converted = division[0].movePointLeft(2);
    1.32 +        BigDecimal converted = division[0].movePointLeft(toFractionDigits);
    1.33 +        converted = converted.setScale(toFractionDigits); //XXX ugly
    1.34          result.setConverted(converted);
    1.35          //result.setRemainder(...);
    1.36          return result;