diff -r 251d0ed461fb -r 58ec6da75f6f task4/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/task4/solution13/src/org/apidesign/apifest08/currency/ExchangeRate.java Sat Oct 11 23:38:46 2008 +0200
@@ -0,0 +1,68 @@
+
+package org.apidesign.apifest08.currency;
+
+import java.math.BigDecimal;
+
+/**
+ * Exchange rate value. Contains from
and to
value.
+ *
+ * @author arnostvalicek
+ */
+public class ExchangeRate {
+ 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; + } + + +// public ExchangeRate createExchangeRate(BigDecimal forValue, BigDecimal getValue) { +// ExchangeRate rate = new ExchangeRate(forValue, getValue); +// return rate; +// } + + + +}