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
     1 package org.apidesign.apifest08.currency;
     2 
     3 import java.util.Currency;
     4 
     5 
     6 /** 
     7  * Converts one currency to other. The conversion is unidirectional. 
     8  * For example you can have convertor that converts USD (sourceCurrency) to CZK (destination currency). You can call the {@link Convertor#convert(Money)} method
     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 
    10  * convertor. To create a convertor instance call {@link ConvertorFactory#createConvertor(Currency, Currency)}.
    11  */
    12 public interface Convertor {
    13 	/**
    14 	 * Converts amount in source currency to amount in destination currency. The result is rounded to two decimal places.
    15 	 * @param money 
    16 	 * @return
    17 	 * @throws IllegalArgumentException if money.getCurrency is not equal to sourceCurrency.
    18 	 */
    19 	public Money convert(Money money);
    20 
    21 	/**
    22 	 * Returns convertor that converts from destination currency to source currency with the same exchange rate. 
    23 	 * @return
    24 	 */
    25 	public Convertor revert();
    26 	
    27 	/**
    28 	 * Returns source currency.
    29 	 * @return
    30 	 */
    31 	public Currency getSourceCurrency();
    32 
    33 	/**
    34 	 * Returns destination currency.
    35 	 * @return
    36 	 */
    37 	public Currency getDestinationCurrency();
    38 }