task2/solution09/src/org/apidesign/apifest08/currency/ConvertorFactory.java
changeset 42 2c8c32ad44f7
parent 41 a7e6f84fb078
child 44 6a500cd1e467
     1.1 --- a/task2/solution09/src/org/apidesign/apifest08/currency/ConvertorFactory.java	Tue Oct 07 01:18:23 2008 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,38 +0,0 @@
     1.4 -package org.apidesign.apifest08.currency;
     1.5 -
     1.6 -import java.math.BigDecimal;
     1.7 -
     1.8 -
     1.9 -public class ConvertorFactory {
    1.10 -
    1.11 -    public static Convertor getConvertor(CurrencyType from, CurrencyType to) {
    1.12 -        if (from == CurrencyType.CZK && to == CurrencyType.USD) {
    1.13 -             return new BasicConvertor(new BigDecimal(17));
    1.14 -        } else if (from == CurrencyType.SKK && to == CurrencyType.CZK) {
    1.15 -            double rate = 0.8d;
    1.16 -            return new BasicConvertor(new BigDecimal(rate));
    1.17 -        }
    1.18 -
    1.19 -
    1.20 -        throw new UnsupportedOperationException("Conversion not supported now");
    1.21 -    }
    1.22 -
    1.23 -    private static class BasicConvertor implements Convertor {
    1.24 -
    1.25 -        private final BigDecimal conversionRate;
    1.26 -
    1.27 -        BasicConvertor(BigDecimal conversionRate) {
    1.28 -            this.conversionRate = conversionRate;
    1.29 -        }
    1.30 -
    1.31 -        @Override
    1.32 -        public long convertTo(long amount) {
    1.33 -            return (long) (conversionRate.doubleValue() * amount);
    1.34 -        }
    1.35 -
    1.36 -        @Override
    1.37 -        public long convertFrom(long amount) {
    1.38 -            return (long) (amount / conversionRate.doubleValue());
    1.39 -        }
    1.40 -    }
    1.41 -}