All Packages Class Hierarchy This Package Previous Next Index
Class com.roguewave.money.currency.v1_0.TriangularExchange
java.lang.Object
|
+----com.roguewave.money.currency.v1_0.Exchange
|
+----com.roguewave.money.currency.v1_0.TriangularExchange
- public class TriangularExchange
- extends Exchange
The TriangularExchange
derives from the abstract base class
Exchange
. A TriangularExchange
object
converts a source currency to a target currency by dividing the original
amount of the source currency by the intermediate to source factor. Then,
it multiplies the resulting value by the intermediate to target factor to
obtain a final value in the target currency. This contrasts with
DivisionExchange
and MultiplicationExchange
which
have a one-step process of conversion.
- Author:
- Trevor Misfeldt
- See Also:
- MultiplicationExchange, DivisionExchange, Exchange, FactoryExample, GroupExample
-
NAME
- The name of this method of conversion is "Triangular"
-
TriangularExchange(String, String, String, double, double)
- Creates a new exchange object with the desired source, target, intermediate
and conversion factor.
-
exchange(Money)
- Exchanges the money to the target currency.
-
getIntermediate()
- Returns the intermediate currency
-
getIntermediateToSourceFactor()
- Returns the intermediate to source conversion factor.
-
getIntermediateToTargetFactor()
- Returns the intermediate to target conversion factor.
-
setIntermediate(String)
- Sets the intermediate currency in the two-step conversion process.
-
setIntermediateToSourceFactor(double)
- Sets the intermediate to source conversion factor.
-
setIntermediateToTargetFactor(double)
- Sets the intermediate to target conversion factor.
NAME
public static final String NAME
- The name of this method of conversion is "Triangular"
TriangularExchange
public TriangularExchange(String source,
String target,
String intermediate,
double intermediateToSource,
double intermediateToTarget)
- Creates a new exchange object with the desired source, target, intermediate
and conversion factor.
- Parameters:
- source - the currency to convert
- target - the desired currency
- intermediate - the intermediate currency in the two-step conversion
- intermediateToSource - the factor to divide the source amount by to
the intermediate amount
- intermediateToTarget - the factor to multiply the intermediate
amount by to get the target amount
setIntermediate
public void setIntermediate(String intermediate)
- Sets the intermediate currency in the two-step conversion process. The source amount
is converted to this currency before being converted to the target currency.
- Parameters:
- intermediate - the desired intermediate currency
getIntermediate
public String getIntermediate()
- Returns the intermediate currency
- Returns:
- the intermediate currency
setIntermediateToSourceFactor
public void setIntermediateToSourceFactor(double factor)
- Sets the intermediate to source conversion factor.
- Parameters:
- factor - the desired conversion factor
getIntermediateToSourceFactor
public double getIntermediateToSourceFactor()
- Returns the intermediate to source conversion factor.
- Returns:
- the intermediate to source conversion factor
setIntermediateToTargetFactor
public void setIntermediateToTargetFactor(double factor)
- Sets the intermediate to target conversion factor.
- Parameters:
- factor - the desired conversion factor
getIntermediateToTargetFactor
public double getIntermediateToTargetFactor()
- Returns the intermediate to target conversion factor.
- Returns:
- the intermediate to target conversion factor
exchange
public Money exchange(Money money)
- Exchanges the money to the target currency. Calls the error handler if money's
currency is not equal to the source currency.
- Parameters:
- money - the money before conversion
- Returns:
- Money in the target currency with a converted value.
- Overrides:
- exchange in class Exchange
All Packages Class Hierarchy This Package Previous Next Index