diff options
Diffstat (limited to 'sandbox/sca-cloud-tutorial/store-catalog-appengine-webapp/src/services/CurrencyConverterImpl.java')
-rw-r--r-- | sandbox/sca-cloud-tutorial/store-catalog-appengine-webapp/src/services/CurrencyConverterImpl.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sandbox/sca-cloud-tutorial/store-catalog-appengine-webapp/src/services/CurrencyConverterImpl.java b/sandbox/sca-cloud-tutorial/store-catalog-appengine-webapp/src/services/CurrencyConverterImpl.java new file mode 100644 index 0000000000..7de3894e2e --- /dev/null +++ b/sandbox/sca-cloud-tutorial/store-catalog-appengine-webapp/src/services/CurrencyConverterImpl.java @@ -0,0 +1,24 @@ +package services; + +import org.oasisopen.sca.annotation.Service; + +@Service(CurrencyConverter.class) +public class CurrencyConverterImpl implements CurrencyConverter { + public double getConversion(String fromCurrencyCode, + String toCurrencyCode, + double amount) { + if (toCurrencyCode.equals("USD")) + return amount; + else if (toCurrencyCode.equals("EUR")) + return ((double)Math.round(amount * 0.7256 * 100)) /100; + return 0; + } + + public String getCurrencySymbol(String currencyCode) { + if (currencyCode.equals("USD")) + return "$"; + else if (currencyCode.equals("EUR")) + return "E"; //"€"; + return "?"; + } +} |