/* * [Exch.java] * * Summary: information about the exchange rate for one country. * * Copyright: (c) 2001-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 3.5 2008-09-19 allow commas in parameter amount values. */ package com.mindprod.currcon; import java.io.Serializable; /** * information about the exchange rate for one country. *

* Kept very simple compile under JDK 1.1 * * @author Roedy Green, Canadian Mind Products * @version 3.5 2008-09-19 allow commas in parameter amount values. * @since 2001 */ public final class Exch implements Serializable { /** * version number for this class. Must be the same as Geom. */ private static final long serialVersionUID = 5L; /** * currency code e.g. USD */ private final String currCode; /** * currency name e.g. US dollars */ private final String currName; /** * The currency symbol, e.g. $ Euro. May display as blob */ private final String symbol; /** * how many decimal places do you typically display this currency. 2 for US and Canada. */ private final int decimalPlaces; /** * exchange rate. Cost in US$ of buying one unit of this currency. e.g. for Canada in the 1990s would be .83 */ private double exchangeRate; /** * Create descriptor for one currency * * @param currCode 3 letter code for the currency, upper case * @param currName description of the currency * @param symbol $ or \ u f f f f to put in front of value. * @param decimalPlaces Number of decimal places to display this currency * @param exchangeRate value of one unit of the currency in US$, for canada will be about .75 */ public Exch( final String currCode, final String currName, final String symbol, final int decimalPlaces, final double exchangeRate ) { if ( currCode.length() != 3 ) { throw new IllegalArgumentException( "Currency Code must be three letters." ); } if ( decimalPlaces < 0 | decimalPlaces > 3 ) { throw new IllegalArgumentException( "bad decimal places in exchange rate table." ); } this.currCode = currCode.toUpperCase(); this.symbol = symbol; this.currName = currName; this.decimalPlaces = decimalPlaces; this.exchangeRate = exchangeRate; } public static long getSerialVersionUID() { return serialVersionUID; } public String getCurrAbbr() { return currCode; } public String getCurrName() { return currName; } public int getDecimalPlaces() { return decimalPlaces; } public double getExchangeRate() { return exchangeRate; } public void setExchangeRate( final double exchangeRate ) { this.exchangeRate = exchangeRate; } public String getSymbol() { return symbol; } } // end Exch