task1/solution02/src/org/apidesign/apifest08/currency/Convertor.java
author japod@localhost
Sun, 28 Sep 2008 14:12:38 +0200
changeset 6 97662396c0fd
child 16 2864c6d744c0
permissions -rw-r--r--
Adding solutions received for task1
japod@6
     1
package org.apidesign.apifest08.currency;
japod@6
     2
japod@6
     3
import java.util.Currency;
japod@6
     4
japod@6
     5
japod@6
     6
/** 
japod@6
     7
 * Converts one currency to other. The conversion is unidirectional. 
japod@6
     8
 * For example you can have convertor that converts USD (sourceCurrency) to CZK (destination currency). You can call the {@link Convertor#convert(Money)} method
japod@6
     9
 * with amount in USD to get the equivalent in CZK. If you need convert CZK to USD you can call {@link Convertor#revert()} method to get CZK to USD 
japod@6
    10
 * convertor. To create a convertor instance call {@link ConvertorFactory#createConvertor(Currency, Currency)}.
japod@6
    11
 */
japod@6
    12
public interface Convertor {
japod@6
    13
	/**
japod@6
    14
	 * Converts amount in source currency to amount in destination currency. The result is rounded to two decimal places.
japod@6
    15
	 * @param money 
japod@6
    16
	 * @return
japod@6
    17
	 * @throws IllegalArgumentException if money.getCurrency is not equal to sourceCurrency.
japod@6
    18
	 */
japod@6
    19
	public Money convert(Money money);
japod@6
    20
japod@6
    21
	/**
japod@6
    22
	 * Returns convertor that converts from destination currency to source currency with the same exchange rate. 
japod@6
    23
	 * @return
japod@6
    24
	 */
japod@6
    25
	public Convertor revert();
japod@6
    26
	
japod@6
    27
	/**
japod@6
    28
	 * Returns source currency.
japod@6
    29
	 * @return
japod@6
    30
	 */
japod@6
    31
	public Currency getSourceCurrency();
japod@6
    32
japod@6
    33
	/**
japod@6
    34
	 * Returns destination currency.
japod@6
    35
	 * @return
japod@6
    36
	 */
japod@6
    37
	public Currency getDestinationCurrency();
japod@6
    38
}