diff -r f6073056b9fe -r a7e6f84fb078 task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java
--- a/task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java Wed Oct 01 10:43:05 2008 +0200
+++ b/task2/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java Tue Oct 07 01:18:23 2008 +0200
@@ -12,20 +12,47 @@
private BigDecimal numberFor;
private BigDecimal numberGet;
+ /**
+ * Constructor for new exchange rate holding two values - from value and to value
+ * @param fromValue Exchange rate from value
+ * @param toValue Exchange rate to value
+ */
public ExchangeRate(BigDecimal fromValue, BigDecimal toValue) {
this.numberFor = fromValue;
this.numberGet = toValue;
}
+
+ /**
+ * Create new instance of ExchangeRate
based on provided exchange rate, but swapping its
+ * from and to value.
+ *
+ * Provided exchange rate is not chaged, this method returns different instance describing reverted exchange rate. + * + * @param rate Exchange rate which describes rate to be reverted. + * @return Instance of reverted rate. + */ + public static ExchangeRate createRevertedRate(ExchangeRate rate) { + ExchangeRate reverted = new ExchangeRate(rate.getToValue(), rate.getFromValue()); + return reverted; + } @Override public String toString() { return "for "+numberFor+" recieve "+numberGet+" @"+getClass().getName(); } + /** + * Return exchange rate from value stored in this object. + * @return Returns from value for this exchange rate. + */ public BigDecimal getFromValue() { return numberFor; } + /** + * Return exchange rate to value stored in this object. + * @return Returns to value for this exchange rate. + */ public BigDecimal getToValue() { return numberGet; }