task4/solution14/src/org/apidesign/apifest08/currency/CurrencyRateImpl.java
changeset 61 58ec6da75f6f
parent 50 03c5c5dc94e7
child 67 bf7622ec1713
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/task4/solution14/src/org/apidesign/apifest08/currency/CurrencyRateImpl.java	Sat Oct 11 23:38:46 2008 +0200
     1.3 @@ -0,0 +1,37 @@
     1.4 +
     1.5 +package org.apidesign.apifest08.currency;
     1.6 +
     1.7 +public final class CurrencyRateImpl implements CurrencyRate {
     1.8 +    private String currency1;
     1.9 +    private String currency2;
    1.10 +    private Rate rate;
    1.11 +    
    1.12 +    CurrencyRateImpl(final String currency1, final String currency2, final Rate rate) {
    1.13 +        if ((currency1 == null)||(currency2 == null) || (rate == null)) {
    1.14 +            throw new IllegalArgumentException("Argument cannot be null.");
    1.15 +        }
    1.16 +        if ("".equals(currency1) || "".equals(currency2)) {
    1.17 +            throw new IllegalArgumentException("Name of currency cannot be empty string");
    1.18 +        }
    1.19 +        if (currency1.equals(currency2)) {
    1.20 +            throw new IllegalArgumentException("Currencies in rate cannot be the same");
    1.21 +        }
    1.22 +       
    1.23 +        this.currency1 = currency1;
    1.24 +        this.currency2 = currency2;
    1.25 +        this.rate = rate;
    1.26 +    }
    1.27 +
    1.28 +    public String getCurrency1() {
    1.29 +        return currency1;
    1.30 +    }
    1.31 +            
    1.32 +    public String getCurrency2() {
    1.33 +        return currency2;
    1.34 +    }
    1.35 +
    1.36 +    public Rate getRate(){
    1.37 +        return rate;
    1.38 +    }
    1.39 +
    1.40 +}