All Packages Class Hierarchy This Package Previous Next Index
Class com.roguewave.examples.money.currency.v1_0.USDollarExchange
java.lang.Object
|
+----com.roguewave.money.currency.v1_0.Exchange
|
+----com.roguewave.examples.money.currency.v1_0.USDollarExchange
- public class USDollarExchange
- extends Exchange
An Exchange
class encapsulates a source currency, a target
currency and an algorithm for converting amounts in the source currency
into amounts in the target currency.
I have exchange rates for a lot currencies. Trouble is, the rates
are all for converting currencies to and from US Dollars. There are
no rates for converting currency x to currency y when neither x nor
y are US Dollars. I can, however, convert from x to y by first
converting x to US Dollars and then converting that amount to
currency y since I do have rates for converting x and y to and from
US Dollars.
The USDollarExchange
implements the above exchange
strategy. It may be used by itself or as an implementation for the
Exchange
class.
- Author:
- Trevor Misfeldt
- See Also:
- Exchange, USDollarGroup
-
NAME
- The name of this conversion method is "USDollar Method"
-
USDollarExchange(String, String, double, double)
- Creates a new US Dollar exchange with a source, target and factors to use the US
Dollar as a go between to convert the source to the target.
-
exchange(Money)
- Method to exchange one money for another by first converting the source
to the US dollar and then converting the US dollar to the target
currency.
-
getDollarToTargetFactor()
- Returns the USD->target factor.
-
getName()
- Returns the name of this conversion exchange method.
-
getSourceToDollarFactor()
- Returns the source->USD factor.
-
setDollarToTargetFactor(double)
- Sets the USD->target factor.
-
setSourceToDollarFactor(double)
- Sets the source->USD factor.
NAME
public static String NAME
- The name of this conversion method is "USDollar Method"
USDollarExchange
public USDollarExchange(String source,
String target,
double sourceToDollarFactor,
double dollarToTargetFactor)
- Creates a new US Dollar exchange with a source, target and factors to use the US
Dollar as a go between to convert the source to the target.
- Parameters:
- source - the souce currency mnemonic
- target - the target currency mnemonic
- sourceToDollarFactor - the source->USD factor
- dollarToTargetFactor - the USD->target factor
getName
public String getName()
- Returns the name of this conversion exchange method.
- Returns:
- the name
- Overrides:
- getName in class Exchange
- See Also:
- NAME
getSourceToDollarFactor
public double getSourceToDollarFactor()
- Returns the source->USD factor.
- Returns:
- the factor
setSourceToDollarFactor
public void setSourceToDollarFactor(double sourceToDollarFactor)
- Sets the source->USD factor.
- Parameters:
- sourceToDollarFactor - the factor for converting source->USD
getDollarToTargetFactor
public double getDollarToTargetFactor()
- Returns the USD->target factor.
- Returns:
- the factor
setDollarToTargetFactor
public void setDollarToTargetFactor(double dollarToTargetFactor)
- Sets the USD->target factor.
- Parameters:
- dollarToTargetFactor - the factor for converting USD->target
exchange
public Money exchange(Money money)
- Method to exchange one money for another by first converting the source
to the US dollar and then converting the US dollar to the target
currency.
- Parameters:
- money - original money to convert
- Returns:
- the converted money
- Overrides:
- exchange in class Exchange
All Packages Class Hierarchy This Package Previous Next Index