1.1 --- a/task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java Wed Oct 01 10:43:05 2008 +0200
1.2 +++ b/task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java Tue Oct 07 01:18:23 2008 +0200
1.3 @@ -12,20 +12,47 @@
1.4 private BigDecimal numberFor;
1.5 private BigDecimal numberGet;
1.6
1.7 + /**
1.8 + * Constructor for new exchange rate holding two values - <em>from value</em> and <em>to value</em>
1.9 + * @param fromValue Exchange rate <em>from value</em>
1.10 + * @param toValue Exchange rate <em>to value</em>
1.11 + */
1.12 public ExchangeRate(BigDecimal fromValue, BigDecimal toValue) {
1.13 this.numberFor = fromValue;
1.14 this.numberGet = toValue;
1.15 }
1.16 +
1.17 + /**
1.18 + * Create new instance of <code>ExchangeRate</code> based on provided exchange rate, but swapping its
1.19 + * <em>from</em> and <em>to</em> value.
1.20 + * <p>
1.21 + * Provided exchange rate is not chaged, this method returns different instance describing reverted exchange rate.
1.22 + *
1.23 + * @param rate Exchange rate which describes rate to be reverted.
1.24 + * @return Instance of reverted rate.
1.25 + */
1.26 + public static ExchangeRate createRevertedRate(ExchangeRate rate) {
1.27 + ExchangeRate reverted = new ExchangeRate(rate.getToValue(), rate.getFromValue());
1.28 + return reverted;
1.29 + }
1.30
1.31 @Override
1.32 public String toString() {
1.33 return "for "+numberFor+" recieve "+numberGet+" @"+getClass().getName();
1.34 }
1.35
1.36 + /**
1.37 + * Return exchange rate <em>from</em> value stored in this object.
1.38 + * @return Returns <em>from</em> value for this exchange rate.
1.39 + */
1.40 public BigDecimal getFromValue() {
1.41 return numberFor;
1.42 }
1.43
1.44 + /**
1.45 + * Return exchange rate <em>to</em> value stored in this object.
1.46 + * @return Returns <em>to</em> value for this exchange rate.
1.47 + */
1.48 public BigDecimal getToValue() {
1.49 return numberGet;
1.50 }