task2/solution14/src/org/apidesign/apifest08/currency/CurrencyRateImpl.java
author japod@localhost
Wed, 08 Oct 2008 12:51:52 +0200
changeset 49 de033c457bed
permissions -rw-r--r--
adding solution14 for task2
japod@49
     1
japod@49
     2
package org.apidesign.apifest08.currency;
japod@49
     3
japod@49
     4
public final class CurrencyRateImpl implements CurrencyRate {
japod@49
     5
    private String currency1;
japod@49
     6
    private String currency2;
japod@49
     7
    private Rate rate;
japod@49
     8
    
japod@49
     9
    CurrencyRateImpl(final String currency1, final String currency2, final Rate rate) {
japod@49
    10
        if ((currency1 == null)||(currency2 == null) || (rate == null)) {
japod@49
    11
            throw new IllegalArgumentException("Argument cannot be null.");
japod@49
    12
        }
japod@49
    13
        if ("".equals(currency1) || "".equals(currency2)) {
japod@49
    14
            throw new IllegalArgumentException("Name of currency cannot be empty string");
japod@49
    15
        }
japod@49
    16
        if (currency1.equals(currency2)) {
japod@49
    17
            throw new IllegalArgumentException("Currencies in rate cannot be the same");
japod@49
    18
        }
japod@49
    19
       
japod@49
    20
        this.currency1 = currency1;
japod@49
    21
        this.currency2 = currency2;
japod@49
    22
        this.rate = rate;
japod@49
    23
    }
japod@49
    24
japod@49
    25
    public String getCurrency1() {
japod@49
    26
        return currency1;
japod@49
    27
    }
japod@49
    28
            
japod@49
    29
    public String getCurrency2() {
japod@49
    30
        return currency2;
japod@49
    31
    }
japod@49
    32
japod@49
    33
    public Rate getRate(){
japod@49
    34
        return rate;
japod@49
    35
    }
japod@49
    36
japod@49
    37
}