task1/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java
author japod@localhost
Sun, 28 Sep 2008 14:12:38 +0200
changeset 6 97662396c0fd
permissions -rw-r--r--
Adding solutions received for task1
     1 package org.apidesign.apifest08.currency;
     2 
     3 /**
     4  * Convertor factory is a factory class for creating {@link Convertor Convertor}
     5  * instances.
     6  *
     7  * @author jindra
     8  */
     9 public final class ConvertorFactory {
    10 
    11     // this class needs no instances
    12     private ConvertorFactory() {
    13     }
    14 
    15 
    16     /**
    17      * Create a {@link Convertor Convertor} with given exchange rate
    18      *
    19      * @param exchangeRate double reprezenting the exchange rate from primary currency into
    20      * the secundary currecny
    21      * @return {@link Convertor Convertor} instance with given exchange rate
    22      */
    23     public static Convertor createConvertor(double exchangeRate) {
    24         if (exchangeRate == 0) {
    25             throw new IllegalArgumentException("Zero exchange rate is not allowed.");
    26         }
    27         return new ConvertorImpl(exchangeRate);
    28 
    29     }
    30 }