diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-03 13:36:24 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-03 13:36:24 +0000 |
commit | decdb7869ac71c291b835db1b291172b73e3c280 (patch) | |
tree | 0eca72e470f26cb889fddf122a5bd9cdb7ea8352 /sandbox/travelsample/currency-contribution | |
parent | 2039d195339d7790cb584e19058deeaf7db95829 (diff) |
Updates to add in cars and flights
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@682170 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/currency-contribution')
-rw-r--r-- | sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java b/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java index 06d1d23535..eddc59f555 100644 --- a/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java +++ b/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java @@ -18,6 +18,9 @@ */ package scatours.currencyconverter; +import java.util.HashMap; +import java.util.Map; + import org.osoa.sca.annotations.Service; /** @@ -25,10 +28,24 @@ import org.osoa.sca.annotations.Service; */ @Service(interfaces={CurrencyConverter.class}) public class CurrencyConverterImpl implements CurrencyConverter { + + // currency index + private Map<String, Integer> currencyIndex = new HashMap<String, Integer>(); + + // exchange rates + private final double rates [][] = {{ 1.00, 0.50, 0.66 }, + { 2.00, 1.00, 1.33 }, + { 1.50, 0.75, 1.00 } } ; + + public CurrencyConverterImpl(){ + currencyIndex.put("USD", new Integer(0)); + currencyIndex.put("GBP", new Integer(1)); + currencyIndex.put("EUR", new Integer(2)); + } public double getExchangeRate(String fromCurrencyCode, String toCurrencyCode){ - // regardless of which currencies are specified return the same value - return 1.98; + return rates[currencyIndex.get(fromCurrencyCode).intValue()] + [currencyIndex.get(toCurrencyCode).intValue()]; } public double convert(String fromCurrencyCode, String toCurrencyCode, double amount){ |