1.1 --- a/task2/solution03/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,41 +0,0 @@
1.4 -package org.apidesign.apifest08.currency;
1.5 -
1.6 -/** This is the skeleton class for your API. You need to make it public, so
1.7 - * it is accessible to your client code (currently in Task1Test.java) file.
1.8 - * <p>
1.9 - * Feel free to create additional classes or rename this one, just keep all
1.10 - * the API and its implementation in this package. Do not spread it outside
1.11 - * to other packages.
1.12 - */
1.13 -public class Convertor {
1.14 -
1.15 - public static final int FIRST_TO_SECOND = 1;
1.16 -
1.17 - public static final int SECOND_TO_FIRST = 2;
1.18 -
1.19 - private double first;
1.20 -
1.21 - private double second;
1.22 -
1.23 - public Convertor(double first, double second) {
1.24 - this.first = first;
1.25 - this.second = second;
1.26 - }
1.27 -
1.28 - public double convertFirstToSecond(double value) {
1.29 - return (second / first) * value;
1.30 - }
1.31 -
1.32 - public double convertSecondToFirst(double value) {
1.33 - return (first / second) * value;
1.34 - }
1.35 -
1.36 - public double convert(double value, int typeOfConvert) {
1.37 - if (FIRST_TO_SECOND == typeOfConvert) {
1.38 - return convertFirstToSecond(value);
1.39 - } else if (SECOND_TO_FIRST == typeOfConvert) {
1.40 - return convertSecondToFirst(value);
1.41 - }
1.42 - throw new IllegalArgumentException("Unkown type of convert.");
1.43 - }
1.44 -}