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

Variable Index

 o NAME
The name of this method of conversion is "Triangular"

Constructor Index

 o TriangularExchange(String, String, String, double, double)
Creates a new exchange object with the desired source, target, intermediate and conversion factor.

Method Index

 o exchange(Money)
Exchanges the money to the target currency.
 o getIntermediate()
Returns the intermediate currency
 o getIntermediateToSourceFactor()
Returns the intermediate to source conversion factor.
 o getIntermediateToTargetFactor()
Returns the intermediate to target conversion factor.
 o setIntermediate(String)
Sets the intermediate currency in the two-step conversion process.
 o setIntermediateToSourceFactor(double)
Sets the intermediate to source conversion factor.
 o setIntermediateToTargetFactor(double)
Sets the intermediate to target conversion factor.

Variables

 o NAME
 public static final String NAME
The name of this method of conversion is "Triangular"

Constructors

 o 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

Methods

 o 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
 o getIntermediate
 public String getIntermediate()
Returns the intermediate currency

Returns:
the intermediate currency
 o setIntermediateToSourceFactor
 public void setIntermediateToSourceFactor(double factor)
Sets the intermediate to source conversion factor.

Parameters:
factor - the desired conversion factor
 o getIntermediateToSourceFactor
 public double getIntermediateToSourceFactor()
Returns the intermediate to source conversion factor.

Returns:
the intermediate to source conversion factor
 o setIntermediateToTargetFactor
 public void setIntermediateToTargetFactor(double factor)
Sets the intermediate to target conversion factor.

Parameters:
factor - the desired conversion factor
 o getIntermediateToTargetFactor
 public double getIntermediateToTargetFactor()
Returns the intermediate to target conversion factor.

Returns:
the intermediate to target conversion factor
 o 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