Owner of solution 2 did not sent the solution for task 4, as far as I can tell
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Fri, 17 Oct 2008 17:42:16 +0200
changeset 706f4b6952f988
parent 69 420baec87dc5
child 71 978f6a78c22e
Owner of solution 2 did not sent the solution for task 4, as far as I can tell
task4/solution02/build.xml
task4/solution02/nbproject/build-impl.xml
task4/solution02/nbproject/genfiles.properties
task4/solution02/nbproject/project.properties
task4/solution02/nbproject/project.xml
task4/solution02/src/org/apidesign/apifest08/currency/CompositeConvertor.java
task4/solution02/src/org/apidesign/apifest08/currency/Convertor.java
task4/solution02/src/org/apidesign/apifest08/currency/ConvertorFactory.java
task4/solution02/src/org/apidesign/apifest08/currency/DefaultConvertor.java
task4/solution02/src/org/apidesign/apifest08/currency/ExtendedConvertor.java
task4/solution02/src/org/apidesign/apifest08/currency/Money.java
task4/solution02/src/org/apidesign/apifest08/currency/MoneyImpl.java
task4/solution02/test/org/apidesign/apifest08/currency/CompositeConvertorTest.java
task4/solution02/test/org/apidesign/apifest08/test/ConvertorFactoryTest.java
task4/solution02/test/org/apidesign/apifest08/test/ConvertorTest.java
task4/solution02/test/org/apidesign/apifest08/test/MoneyTest.java
task4/solution02/test/org/apidesign/apifest08/test/OnlineConvertor.java
task4/solution02/test/org/apidesign/apifest08/test/OnlineConvertorTest.java
task4/solution02/test/org/apidesign/apifest08/test/Task1Test.java
task4/solution02/test/org/apidesign/apifest08/test/Task2Test.java
task4/solution02/test/org/apidesign/apifest08/test/Task3Test.java
task4/solution02/test/org/apidesign/apifest08/test/Task4Test.java
     1.1 --- a/task4/solution02/build.xml	Fri Oct 17 17:40:14 2008 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,69 +0,0 @@
     1.4 -<?xml version="1.0" encoding="UTF-8"?>
     1.5 -<!-- You may freely edit this file. See commented blocks below for -->
     1.6 -<!-- some examples of how to customize the build. -->
     1.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
     1.8 -<project name="currency" default="default" basedir=".">
     1.9 -    <description>Builds, tests, and runs the project.</description>
    1.10 -    <import file="nbproject/build-impl.xml"/>
    1.11 -    <!--
    1.12 -
    1.13 -    There exist several targets which are by default empty and which can be 
    1.14 -    used for execution of your tasks. These targets are usually executed 
    1.15 -    before and after some main targets. They are: 
    1.16 -
    1.17 -      -pre-init:                 called before initialization of project properties
    1.18 -      -post-init:                called after initialization of project properties
    1.19 -      -pre-compile:              called before javac compilation
    1.20 -      -post-compile:             called after javac compilation
    1.21 -      -pre-compile-single:       called before javac compilation of single file
    1.22 -      -post-compile-single:      called after javac compilation of single file
    1.23 -      -pre-compile-test:         called before javac compilation of JUnit tests
    1.24 -      -post-compile-test:        called after javac compilation of JUnit tests
    1.25 -      -pre-compile-test-single:  called before javac compilation of single JUnit test
    1.26 -      -post-compile-test-single: called after javac compilation of single JUunit test
    1.27 -      -pre-jar:                  called before JAR building
    1.28 -      -post-jar:                 called after JAR building
    1.29 -      -post-clean:               called after cleaning build products
    1.30 -
    1.31 -    (Targets beginning with '-' are not intended to be called on their own.)
    1.32 -
    1.33 -    Example of inserting an obfuscator after compilation could look like this:
    1.34 -
    1.35 -        <target name="-post-compile">
    1.36 -            <obfuscate>
    1.37 -                <fileset dir="${build.classes.dir}"/>
    1.38 -            </obfuscate>
    1.39 -        </target>
    1.40 -
    1.41 -    For list of available properties check the imported 
    1.42 -    nbproject/build-impl.xml file. 
    1.43 -
    1.44 -
    1.45 -    Another way to customize the build is by overriding existing main targets.
    1.46 -    The targets of interest are: 
    1.47 -
    1.48 -      -init-macrodef-javac:     defines macro for javac compilation
    1.49 -      -init-macrodef-junit:     defines macro for junit execution
    1.50 -      -init-macrodef-debug:     defines macro for class debugging
    1.51 -      -init-macrodef-java:      defines macro for class execution
    1.52 -      -do-jar-with-manifest:    JAR building (if you are using a manifest)
    1.53 -      -do-jar-without-manifest: JAR building (if you are not using a manifest)
    1.54 -      run:                      execution of project 
    1.55 -      -javadoc-build:           Javadoc generation
    1.56 -      test-report:              JUnit report generation
    1.57 -
    1.58 -    An example of overriding the target for project execution could look like this:
    1.59 -
    1.60 -        <target name="run" depends="currency-impl.jar">
    1.61 -            <exec dir="bin" executable="launcher.exe">
    1.62 -                <arg file="${dist.jar}"/>
    1.63 -            </exec>
    1.64 -        </target>
    1.65 -
    1.66 -    Notice that the overridden target depends on the jar target and not only on 
    1.67 -    the compile target as the regular run target does. Again, for a list of available 
    1.68 -    properties which you can use, check the target you are overriding in the
    1.69 -    nbproject/build-impl.xml file. 
    1.70 -
    1.71 -    -->
    1.72 -</project>
     2.1 --- a/task4/solution02/nbproject/build-impl.xml	Fri Oct 17 17:40:14 2008 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,642 +0,0 @@
     2.4 -<?xml version="1.0" encoding="UTF-8"?>
     2.5 -<!--
     2.6 -*** GENERATED FROM project.xml - DO NOT EDIT  ***
     2.7 -***         EDIT ../build.xml INSTEAD         ***
     2.8 -
     2.9 -For the purpose of easier reading the script
    2.10 -is divided into following sections:
    2.11 -
    2.12 -  - initialization
    2.13 -  - compilation
    2.14 -  - jar
    2.15 -  - execution
    2.16 -  - debugging
    2.17 -  - javadoc
    2.18 -  - junit compilation
    2.19 -  - junit execution
    2.20 -  - junit debugging
    2.21 -  - applet
    2.22 -  - cleanup
    2.23 -
    2.24 -        -->
    2.25 -<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Currency_Convertor_Solution_02-impl">
    2.26 -    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
    2.27 -    <!-- 
    2.28 -                ======================
    2.29 -                INITIALIZATION SECTION 
    2.30 -                ======================
    2.31 -            -->
    2.32 -    <target name="-pre-init">
    2.33 -        <!-- Empty placeholder for easier customization. -->
    2.34 -        <!-- You can override this target in the ../build.xml file. -->
    2.35 -    </target>
    2.36 -    <target depends="-pre-init" name="-init-private">
    2.37 -        <property file="nbproject/private/config.properties"/>
    2.38 -        <property file="nbproject/private/configs/${config}.properties"/>
    2.39 -        <property file="nbproject/private/private.properties"/>
    2.40 -    </target>
    2.41 -    <target depends="-pre-init,-init-private" name="-init-user">
    2.42 -        <property file="${user.properties.file}"/>
    2.43 -        <!-- The two properties below are usually overridden -->
    2.44 -        <!-- by the active platform. Just a fallback. -->
    2.45 -        <property name="default.javac.source" value="1.4"/>
    2.46 -        <property name="default.javac.target" value="1.4"/>
    2.47 -    </target>
    2.48 -    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
    2.49 -        <property file="nbproject/configs/${config}.properties"/>
    2.50 -        <property file="nbproject/project.properties"/>
    2.51 -    </target>
    2.52 -    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
    2.53 -        <available file="${manifest.file}" property="manifest.available"/>
    2.54 -        <condition property="manifest.available+main.class">
    2.55 -            <and>
    2.56 -                <isset property="manifest.available"/>
    2.57 -                <isset property="main.class"/>
    2.58 -                <not>
    2.59 -                    <equals arg1="${main.class}" arg2="" trim="true"/>
    2.60 -                </not>
    2.61 -            </and>
    2.62 -        </condition>
    2.63 -        <condition property="manifest.available+main.class+mkdist.available">
    2.64 -            <and>
    2.65 -                <istrue value="${manifest.available+main.class}"/>
    2.66 -                <isset property="libs.CopyLibs.classpath"/>
    2.67 -            </and>
    2.68 -        </condition>
    2.69 -        <condition property="have.tests">
    2.70 -            <or>
    2.71 -                <available file="${test.src.dir}"/>
    2.72 -            </or>
    2.73 -        </condition>
    2.74 -        <condition property="have.sources">
    2.75 -            <or>
    2.76 -                <available file="${src.dir}"/>
    2.77 -            </or>
    2.78 -        </condition>
    2.79 -        <condition property="netbeans.home+have.tests">
    2.80 -            <and>
    2.81 -                <isset property="netbeans.home"/>
    2.82 -                <isset property="have.tests"/>
    2.83 -            </and>
    2.84 -        </condition>
    2.85 -        <condition property="no.javadoc.preview">
    2.86 -            <and>
    2.87 -                <isset property="javadoc.preview"/>
    2.88 -                <isfalse value="${javadoc.preview}"/>
    2.89 -            </and>
    2.90 -        </condition>
    2.91 -        <property name="run.jvmargs" value=""/>
    2.92 -        <property name="javac.compilerargs" value=""/>
    2.93 -        <property name="work.dir" value="${basedir}"/>
    2.94 -        <condition property="no.deps">
    2.95 -            <and>
    2.96 -                <istrue value="${no.dependencies}"/>
    2.97 -            </and>
    2.98 -        </condition>
    2.99 -        <property name="javac.debug" value="true"/>
   2.100 -        <property name="javadoc.preview" value="true"/>
   2.101 -        <property name="application.args" value=""/>
   2.102 -        <property name="source.encoding" value="${file.encoding}"/>
   2.103 -        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
   2.104 -            <and>
   2.105 -                <isset property="javadoc.encoding"/>
   2.106 -                <not>
   2.107 -                    <equals arg1="${javadoc.encoding}" arg2=""/>
   2.108 -                </not>
   2.109 -            </and>
   2.110 -        </condition>
   2.111 -        <property name="javadoc.encoding.used" value="${source.encoding}"/>
   2.112 -        <property name="includes" value="**"/>
   2.113 -        <property name="excludes" value=""/>
   2.114 -        <property name="do.depend" value="false"/>
   2.115 -        <condition property="do.depend.true">
   2.116 -            <istrue value="${do.depend}"/>
   2.117 -        </condition>
   2.118 -        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
   2.119 -            <and>
   2.120 -                <isset property="jaxws.endorsed.dir"/>
   2.121 -                <available file="nbproject/jaxws-build.xml"/>
   2.122 -            </and>
   2.123 -        </condition>
   2.124 -    </target>
   2.125 -    <target name="-post-init">
   2.126 -        <!-- Empty placeholder for easier customization. -->
   2.127 -        <!-- You can override this target in the ../build.xml file. -->
   2.128 -    </target>
   2.129 -    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
   2.130 -        <fail unless="src.dir">Must set src.dir</fail>
   2.131 -        <fail unless="test.src.dir">Must set test.src.dir</fail>
   2.132 -        <fail unless="build.dir">Must set build.dir</fail>
   2.133 -        <fail unless="dist.dir">Must set dist.dir</fail>
   2.134 -        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
   2.135 -        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
   2.136 -        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
   2.137 -        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
   2.138 -        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
   2.139 -        <fail unless="dist.jar">Must set dist.jar</fail>
   2.140 -    </target>
   2.141 -    <target name="-init-macrodef-property">
   2.142 -        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
   2.143 -            <attribute name="name"/>
   2.144 -            <attribute name="value"/>
   2.145 -            <sequential>
   2.146 -                <property name="@{name}" value="${@{value}}"/>
   2.147 -            </sequential>
   2.148 -        </macrodef>
   2.149 -    </target>
   2.150 -    <target name="-init-macrodef-javac">
   2.151 -        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
   2.152 -            <attribute default="${src.dir}" name="srcdir"/>
   2.153 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.154 -            <attribute default="${javac.classpath}" name="classpath"/>
   2.155 -            <attribute default="${includes}" name="includes"/>
   2.156 -            <attribute default="${excludes}" name="excludes"/>
   2.157 -            <attribute default="${javac.debug}" name="debug"/>
   2.158 -            <attribute default="" name="sourcepath"/>
   2.159 -            <element name="customize" optional="true"/>
   2.160 -            <sequential>
   2.161 -                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
   2.162 -                    <classpath>
   2.163 -                        <path path="@{classpath}"/>
   2.164 -                    </classpath>
   2.165 -                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
   2.166 -                    <customize/>
   2.167 -                </javac>
   2.168 -            </sequential>
   2.169 -        </macrodef>
   2.170 -        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
   2.171 -            <attribute default="${src.dir}" name="srcdir"/>
   2.172 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.173 -            <attribute default="${javac.classpath}" name="classpath"/>
   2.174 -            <sequential>
   2.175 -                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
   2.176 -                    <classpath>
   2.177 -                        <path path="@{classpath}"/>
   2.178 -                    </classpath>
   2.179 -                </depend>
   2.180 -            </sequential>
   2.181 -        </macrodef>
   2.182 -        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
   2.183 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.184 -            <sequential>
   2.185 -                <fail unless="javac.includes">Must set javac.includes</fail>
   2.186 -                <pathconvert pathsep="," property="javac.includes.binary">
   2.187 -                    <path>
   2.188 -                        <filelist dir="@{destdir}" files="${javac.includes}"/>
   2.189 -                    </path>
   2.190 -                    <globmapper from="*.java" to="*.class"/>
   2.191 -                </pathconvert>
   2.192 -                <delete>
   2.193 -                    <files includes="${javac.includes.binary}"/>
   2.194 -                </delete>
   2.195 -            </sequential>
   2.196 -        </macrodef>
   2.197 -    </target>
   2.198 -    <target name="-init-macrodef-junit">
   2.199 -        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
   2.200 -            <attribute default="${includes}" name="includes"/>
   2.201 -            <attribute default="${excludes}" name="excludes"/>
   2.202 -            <attribute default="**" name="testincludes"/>
   2.203 -            <sequential>
   2.204 -                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
   2.205 -                    <batchtest todir="${build.test.results.dir}">
   2.206 -                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
   2.207 -                            <filename name="@{testincludes}"/>
   2.208 -                        </fileset>
   2.209 -                    </batchtest>
   2.210 -                    <classpath>
   2.211 -                        <path path="${run.test.classpath}"/>
   2.212 -                    </classpath>
   2.213 -                    <syspropertyset>
   2.214 -                        <propertyref prefix="test-sys-prop."/>
   2.215 -                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
   2.216 -                    </syspropertyset>
   2.217 -                    <formatter type="brief" usefile="false"/>
   2.218 -                    <formatter type="xml"/>
   2.219 -                    <jvmarg line="${run.jvmargs}"/>
   2.220 -                </junit>
   2.221 -            </sequential>
   2.222 -        </macrodef>
   2.223 -    </target>
   2.224 -    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
   2.225 -        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
   2.226 -            <attribute default="${main.class}" name="name"/>
   2.227 -            <attribute default="${debug.classpath}" name="classpath"/>
   2.228 -            <attribute default="" name="stopclassname"/>
   2.229 -            <sequential>
   2.230 -                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
   2.231 -                    <classpath>
   2.232 -                        <path path="@{classpath}"/>
   2.233 -                    </classpath>
   2.234 -                </nbjpdastart>
   2.235 -            </sequential>
   2.236 -        </macrodef>
   2.237 -        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
   2.238 -            <attribute default="${build.classes.dir}" name="dir"/>
   2.239 -            <sequential>
   2.240 -                <nbjpdareload>
   2.241 -                    <fileset dir="@{dir}" includes="${fix.classes}">
   2.242 -                        <include name="${fix.includes}*.class"/>
   2.243 -                    </fileset>
   2.244 -                </nbjpdareload>
   2.245 -            </sequential>
   2.246 -        </macrodef>
   2.247 -    </target>
   2.248 -    <target name="-init-debug-args">
   2.249 -        <property name="version-output" value="java version &quot;${ant.java.version}"/>
   2.250 -        <condition property="have-jdk-older-than-1.4">
   2.251 -            <or>
   2.252 -                <contains string="${version-output}" substring="java version &quot;1.0"/>
   2.253 -                <contains string="${version-output}" substring="java version &quot;1.1"/>
   2.254 -                <contains string="${version-output}" substring="java version &quot;1.2"/>
   2.255 -                <contains string="${version-output}" substring="java version &quot;1.3"/>
   2.256 -            </or>
   2.257 -        </condition>
   2.258 -        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
   2.259 -            <istrue value="${have-jdk-older-than-1.4}"/>
   2.260 -        </condition>
   2.261 -        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
   2.262 -            <os family="windows"/>
   2.263 -        </condition>
   2.264 -        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
   2.265 -            <isset property="debug.transport"/>
   2.266 -        </condition>
   2.267 -    </target>
   2.268 -    <target depends="-init-debug-args" name="-init-macrodef-debug">
   2.269 -        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
   2.270 -            <attribute default="${main.class}" name="classname"/>
   2.271 -            <attribute default="${debug.classpath}" name="classpath"/>
   2.272 -            <element name="customize" optional="true"/>
   2.273 -            <sequential>
   2.274 -                <java classname="@{classname}" dir="${work.dir}" fork="true">
   2.275 -                    <jvmarg line="${debug-args-line}"/>
   2.276 -                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
   2.277 -                    <jvmarg line="${run.jvmargs}"/>
   2.278 -                    <classpath>
   2.279 -                        <path path="@{classpath}"/>
   2.280 -                    </classpath>
   2.281 -                    <syspropertyset>
   2.282 -                        <propertyref prefix="run-sys-prop."/>
   2.283 -                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
   2.284 -                    </syspropertyset>
   2.285 -                    <customize/>
   2.286 -                </java>
   2.287 -            </sequential>
   2.288 -        </macrodef>
   2.289 -    </target>
   2.290 -    <target name="-init-macrodef-java">
   2.291 -        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
   2.292 -            <attribute default="${main.class}" name="classname"/>
   2.293 -            <element name="customize" optional="true"/>
   2.294 -            <sequential>
   2.295 -                <java classname="@{classname}" dir="${work.dir}" fork="true">
   2.296 -                    <jvmarg line="${run.jvmargs}"/>
   2.297 -                    <classpath>
   2.298 -                        <path path="${run.classpath}"/>
   2.299 -                    </classpath>
   2.300 -                    <syspropertyset>
   2.301 -                        <propertyref prefix="run-sys-prop."/>
   2.302 -                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
   2.303 -                    </syspropertyset>
   2.304 -                    <customize/>
   2.305 -                </java>
   2.306 -            </sequential>
   2.307 -        </macrodef>
   2.308 -    </target>
   2.309 -    <target name="-init-presetdef-jar">
   2.310 -        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
   2.311 -            <jar compress="${jar.compress}" jarfile="${dist.jar}">
   2.312 -                <j2seproject1:fileset dir="${build.classes.dir}"/>
   2.313 -            </jar>
   2.314 -        </presetdef>
   2.315 -    </target>
   2.316 -    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
   2.317 -    <!--
   2.318 -                ===================
   2.319 -                COMPILATION SECTION
   2.320 -                ===================
   2.321 -            -->
   2.322 -    <target depends="init" name="deps-jar" unless="no.deps"/>
   2.323 -    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
   2.324 -    <target depends="init" name="-check-automatic-build">
   2.325 -        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
   2.326 -    </target>
   2.327 -    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
   2.328 -        <antcall target="clean"/>
   2.329 -    </target>
   2.330 -    <target depends="init,deps-jar" name="-pre-pre-compile">
   2.331 -        <mkdir dir="${build.classes.dir}"/>
   2.332 -    </target>
   2.333 -    <target name="-pre-compile">
   2.334 -        <!-- Empty placeholder for easier customization. -->
   2.335 -        <!-- You can override this target in the ../build.xml file. -->
   2.336 -    </target>
   2.337 -    <target if="do.depend.true" name="-compile-depend">
   2.338 -        <j2seproject3:depend/>
   2.339 -    </target>
   2.340 -    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
   2.341 -        <j2seproject3:javac/>
   2.342 -        <copy todir="${build.classes.dir}">
   2.343 -            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   2.344 -        </copy>
   2.345 -    </target>
   2.346 -    <target name="-post-compile">
   2.347 -        <!-- Empty placeholder for easier customization. -->
   2.348 -        <!-- You can override this target in the ../build.xml file. -->
   2.349 -    </target>
   2.350 -    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
   2.351 -    <target name="-pre-compile-single">
   2.352 -        <!-- Empty placeholder for easier customization. -->
   2.353 -        <!-- You can override this target in the ../build.xml file. -->
   2.354 -    </target>
   2.355 -    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
   2.356 -        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
   2.357 -        <j2seproject3:force-recompile/>
   2.358 -        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
   2.359 -    </target>
   2.360 -    <target name="-post-compile-single">
   2.361 -        <!-- Empty placeholder for easier customization. -->
   2.362 -        <!-- You can override this target in the ../build.xml file. -->
   2.363 -    </target>
   2.364 -    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
   2.365 -    <!--
   2.366 -                ====================
   2.367 -                JAR BUILDING SECTION
   2.368 -                ====================
   2.369 -            -->
   2.370 -    <target depends="init" name="-pre-pre-jar">
   2.371 -        <dirname file="${dist.jar}" property="dist.jar.dir"/>
   2.372 -        <mkdir dir="${dist.jar.dir}"/>
   2.373 -    </target>
   2.374 -    <target name="-pre-jar">
   2.375 -        <!-- Empty placeholder for easier customization. -->
   2.376 -        <!-- You can override this target in the ../build.xml file. -->
   2.377 -    </target>
   2.378 -    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
   2.379 -        <j2seproject1:jar/>
   2.380 -    </target>
   2.381 -    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
   2.382 -        <j2seproject1:jar manifest="${manifest.file}"/>
   2.383 -    </target>
   2.384 -    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
   2.385 -        <j2seproject1:jar manifest="${manifest.file}">
   2.386 -            <j2seproject1:manifest>
   2.387 -                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
   2.388 -            </j2seproject1:manifest>
   2.389 -        </j2seproject1:jar>
   2.390 -        <echo>To run this application from the command line without Ant, try:</echo>
   2.391 -        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
   2.392 -        <property location="${dist.jar}" name="dist.jar.resolved"/>
   2.393 -        <pathconvert property="run.classpath.with.dist.jar">
   2.394 -            <path path="${run.classpath}"/>
   2.395 -            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
   2.396 -        </pathconvert>
   2.397 -        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
   2.398 -    </target>
   2.399 -    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
   2.400 -        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
   2.401 -        <pathconvert property="run.classpath.without.build.classes.dir">
   2.402 -            <path path="${run.classpath}"/>
   2.403 -            <map from="${build.classes.dir.resolved}" to=""/>
   2.404 -        </pathconvert>
   2.405 -        <pathconvert pathsep=" " property="jar.classpath">
   2.406 -            <path path="${run.classpath.without.build.classes.dir}"/>
   2.407 -            <chainedmapper>
   2.408 -                <flattenmapper/>
   2.409 -                <globmapper from="*" to="lib/*"/>
   2.410 -            </chainedmapper>
   2.411 -        </pathconvert>
   2.412 -        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
   2.413 -        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
   2.414 -            <fileset dir="${build.classes.dir}"/>
   2.415 -            <manifest>
   2.416 -                <attribute name="Main-Class" value="${main.class}"/>
   2.417 -                <attribute name="Class-Path" value="${jar.classpath}"/>
   2.418 -            </manifest>
   2.419 -        </copylibs>
   2.420 -        <echo>To run this application from the command line without Ant, try:</echo>
   2.421 -        <property location="${dist.jar}" name="dist.jar.resolved"/>
   2.422 -        <echo>java -jar "${dist.jar.resolved}"</echo>
   2.423 -    </target>
   2.424 -    <target name="-post-jar">
   2.425 -        <!-- Empty placeholder for easier customization. -->
   2.426 -        <!-- You can override this target in the ../build.xml file. -->
   2.427 -    </target>
   2.428 -    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
   2.429 -    <!--
   2.430 -                =================
   2.431 -                EXECUTION SECTION
   2.432 -                =================
   2.433 -            -->
   2.434 -    <target depends="init,compile" description="Run a main class." name="run">
   2.435 -        <j2seproject1:java>
   2.436 -            <customize>
   2.437 -                <arg line="${application.args}"/>
   2.438 -            </customize>
   2.439 -        </j2seproject1:java>
   2.440 -    </target>
   2.441 -    <target name="-do-not-recompile">
   2.442 -        <property name="javac.includes.binary" value=""/>
   2.443 -    </target>
   2.444 -    <target depends="init,-do-not-recompile,compile-single" name="run-single">
   2.445 -        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
   2.446 -        <j2seproject1:java classname="${run.class}"/>
   2.447 -    </target>
   2.448 -    <!--
   2.449 -                =================
   2.450 -                DEBUGGING SECTION
   2.451 -                =================
   2.452 -            -->
   2.453 -    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
   2.454 -        <j2seproject1:nbjpdastart name="${debug.class}"/>
   2.455 -    </target>
   2.456 -    <target depends="init,compile" name="-debug-start-debuggee">
   2.457 -        <j2seproject3:debug>
   2.458 -            <customize>
   2.459 -                <arg line="${application.args}"/>
   2.460 -            </customize>
   2.461 -        </j2seproject3:debug>
   2.462 -    </target>
   2.463 -    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
   2.464 -    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
   2.465 -        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
   2.466 -    </target>
   2.467 -    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
   2.468 -    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
   2.469 -        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
   2.470 -        <j2seproject3:debug classname="${debug.class}"/>
   2.471 -    </target>
   2.472 -    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
   2.473 -    <target depends="init" name="-pre-debug-fix">
   2.474 -        <fail unless="fix.includes">Must set fix.includes</fail>
   2.475 -        <property name="javac.includes" value="${fix.includes}.java"/>
   2.476 -    </target>
   2.477 -    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
   2.478 -        <j2seproject1:nbjpdareload/>
   2.479 -    </target>
   2.480 -    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
   2.481 -    <!--
   2.482 -                ===============
   2.483 -                JAVADOC SECTION
   2.484 -                ===============
   2.485 -            -->
   2.486 -    <target depends="init" name="-javadoc-build">
   2.487 -        <mkdir dir="${dist.javadoc.dir}"/>
   2.488 -        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
   2.489 -            <classpath>
   2.490 -                <path path="${javac.classpath}"/>
   2.491 -            </classpath>
   2.492 -            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
   2.493 -                <filename name="**/*.java"/>
   2.494 -            </fileset>
   2.495 -        </javadoc>
   2.496 -    </target>
   2.497 -    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
   2.498 -        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
   2.499 -    </target>
   2.500 -    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
   2.501 -    <!--
   2.502 -                =========================
   2.503 -                JUNIT COMPILATION SECTION
   2.504 -                =========================
   2.505 -            -->
   2.506 -    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
   2.507 -        <mkdir dir="${build.test.classes.dir}"/>
   2.508 -    </target>
   2.509 -    <target name="-pre-compile-test">
   2.510 -        <!-- Empty placeholder for easier customization. -->
   2.511 -        <!-- You can override this target in the ../build.xml file. -->
   2.512 -    </target>
   2.513 -    <target if="do.depend.true" name="-compile-test-depend">
   2.514 -        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
   2.515 -    </target>
   2.516 -    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
   2.517 -        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
   2.518 -        <copy todir="${build.test.classes.dir}">
   2.519 -            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   2.520 -        </copy>
   2.521 -    </target>
   2.522 -    <target name="-post-compile-test">
   2.523 -        <!-- Empty placeholder for easier customization. -->
   2.524 -        <!-- You can override this target in the ../build.xml file. -->
   2.525 -    </target>
   2.526 -    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
   2.527 -    <target name="-pre-compile-test-single">
   2.528 -        <!-- Empty placeholder for easier customization. -->
   2.529 -        <!-- You can override this target in the ../build.xml file. -->
   2.530 -    </target>
   2.531 -    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
   2.532 -        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
   2.533 -        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
   2.534 -        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
   2.535 -        <copy todir="${build.test.classes.dir}">
   2.536 -            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
   2.537 -        </copy>
   2.538 -    </target>
   2.539 -    <target name="-post-compile-test-single">
   2.540 -        <!-- Empty placeholder for easier customization. -->
   2.541 -        <!-- You can override this target in the ../build.xml file. -->
   2.542 -    </target>
   2.543 -    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
   2.544 -    <!--
   2.545 -                =======================
   2.546 -                JUNIT EXECUTION SECTION
   2.547 -                =======================
   2.548 -            -->
   2.549 -    <target depends="init" if="have.tests" name="-pre-test-run">
   2.550 -        <mkdir dir="${build.test.results.dir}"/>
   2.551 -    </target>
   2.552 -    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
   2.553 -        <j2seproject3:junit testincludes="**/*Test.java"/>
   2.554 -    </target>
   2.555 -    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
   2.556 -        <fail if="tests.failed">Some tests failed; see details above.</fail>
   2.557 -    </target>
   2.558 -    <target depends="init" if="have.tests" name="test-report"/>
   2.559 -    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
   2.560 -    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
   2.561 -    <target depends="init" if="have.tests" name="-pre-test-run-single">
   2.562 -        <mkdir dir="${build.test.results.dir}"/>
   2.563 -    </target>
   2.564 -    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
   2.565 -        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
   2.566 -        <j2seproject3:junit excludes="" includes="${test.includes}"/>
   2.567 -    </target>
   2.568 -    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
   2.569 -        <fail if="tests.failed">Some tests failed; see details above.</fail>
   2.570 -    </target>
   2.571 -    <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
   2.572 -    <!--
   2.573 -                =======================
   2.574 -                JUNIT DEBUGGING SECTION
   2.575 -                =======================
   2.576 -            -->
   2.577 -    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
   2.578 -        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
   2.579 -        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
   2.580 -        <delete file="${test.report.file}"/>
   2.581 -        <mkdir dir="${build.test.results.dir}"/>
   2.582 -        <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
   2.583 -            <customize>
   2.584 -                <syspropertyset>
   2.585 -                    <propertyref prefix="test-sys-prop."/>
   2.586 -                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
   2.587 -                </syspropertyset>
   2.588 -                <arg value="${test.class}"/>
   2.589 -                <arg value="showoutput=true"/>
   2.590 -                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
   2.591 -                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
   2.592 -            </customize>
   2.593 -        </j2seproject3:debug>
   2.594 -    </target>
   2.595 -    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
   2.596 -        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
   2.597 -    </target>
   2.598 -    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
   2.599 -    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
   2.600 -        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
   2.601 -    </target>
   2.602 -    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
   2.603 -    <!--
   2.604 -                =========================
   2.605 -                APPLET EXECUTION SECTION
   2.606 -                =========================
   2.607 -            -->
   2.608 -    <target depends="init,compile-single" name="run-applet">
   2.609 -        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
   2.610 -        <j2seproject1:java classname="sun.applet.AppletViewer">
   2.611 -            <customize>
   2.612 -                <arg value="${applet.url}"/>
   2.613 -            </customize>
   2.614 -        </j2seproject1:java>
   2.615 -    </target>
   2.616 -    <!--
   2.617 -                =========================
   2.618 -                APPLET DEBUGGING  SECTION
   2.619 -                =========================
   2.620 -            -->
   2.621 -    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
   2.622 -        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
   2.623 -        <j2seproject3:debug classname="sun.applet.AppletViewer">
   2.624 -            <customize>
   2.625 -                <arg value="${applet.url}"/>
   2.626 -            </customize>
   2.627 -        </j2seproject3:debug>
   2.628 -    </target>
   2.629 -    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
   2.630 -    <!--
   2.631 -                ===============
   2.632 -                CLEANUP SECTION
   2.633 -                ===============
   2.634 -            -->
   2.635 -    <target depends="init" name="deps-clean" unless="no.deps"/>
   2.636 -    <target depends="init" name="-do-clean">
   2.637 -        <delete dir="${build.dir}"/>
   2.638 -        <delete dir="${dist.dir}"/>
   2.639 -    </target>
   2.640 -    <target name="-post-clean">
   2.641 -        <!-- Empty placeholder for easier customization. -->
   2.642 -        <!-- You can override this target in the ../build.xml file. -->
   2.643 -    </target>
   2.644 -    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
   2.645 -</project>
     3.1 --- a/task4/solution02/nbproject/genfiles.properties	Fri Oct 17 17:40:14 2008 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,8 +0,0 @@
     3.4 -build.xml.data.CRC32=2ab820eb
     3.5 -build.xml.script.CRC32=58a52595
     3.6 -build.xml.stylesheet.CRC32=be360661
     3.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     3.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     3.9 -nbproject/build-impl.xml.data.CRC32=848e6267
    3.10 -nbproject/build-impl.xml.script.CRC32=6be86987
    3.11 -nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
     4.1 --- a/task4/solution02/nbproject/project.properties	Fri Oct 17 17:40:14 2008 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,68 +0,0 @@
     4.4 -application.title=currency
     4.5 -application.vendor=apidesign.org
     4.6 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
     4.7 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
     4.8 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
     4.9 -build.classes.dir=${build.dir}/classes
    4.10 -build.classes.excludes=**/*.java,**/*.form
    4.11 -# This directory is removed when the project is cleaned:
    4.12 -build.dir=build
    4.13 -build.generated.dir=${build.dir}/generated
    4.14 -# Only compile against the classpath explicitly listed here:
    4.15 -build.sysclasspath=ignore
    4.16 -build.test.classes.dir=${build.dir}/test/classes
    4.17 -build.test.results.dir=${build.dir}/test/results
    4.18 -debug.classpath=\
    4.19 -    ${run.classpath}
    4.20 -debug.test.classpath=\
    4.21 -    ${run.test.classpath}
    4.22 -# This directory is removed when the project is cleaned:
    4.23 -dist.dir=dist
    4.24 -dist.jar=${dist.dir}/currency.jar
    4.25 -dist.javadoc.dir=${dist.dir}/javadoc
    4.26 -excludes=
    4.27 -file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
    4.28 -file.reference.src-apifest08=..
    4.29 -includes=**
    4.30 -jar.compress=false
    4.31 -javac.classpath=
    4.32 -# Space-separated list of extra javac options
    4.33 -javac.compilerargs=
    4.34 -javac.deprecation=false
    4.35 -javac.source=1.5
    4.36 -javac.target=1.5
    4.37 -javac.test.classpath=\
    4.38 -    ${javac.classpath}:\
    4.39 -    ${build.classes.dir}:\
    4.40 -    ${file.reference.junit-4.4.jar}
    4.41 -javadoc.additionalparam=
    4.42 -javadoc.author=false
    4.43 -javadoc.encoding=
    4.44 -javadoc.noindex=false
    4.45 -javadoc.nonavbar=false
    4.46 -javadoc.notree=false
    4.47 -javadoc.private=false
    4.48 -javadoc.splitindex=true
    4.49 -javadoc.use=true
    4.50 -javadoc.version=false
    4.51 -javadoc.windowtitle=
    4.52 -jnlp.codebase.type=local
    4.53 -jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
    4.54 -jnlp.descriptor=application
    4.55 -jnlp.enabled=false
    4.56 -jnlp.offline-allowed=false
    4.57 -jnlp.signed=false
    4.58 -meta.inf.dir=${src.dir}/META-INF
    4.59 -platform.active=default_platform
    4.60 -run.classpath=\
    4.61 -    ${javac.classpath}:\
    4.62 -    ${build.classes.dir}
    4.63 -# Space-separated list of JVM arguments used when running the project
    4.64 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
    4.65 -# or test-sys-prop.name=value to set system properties for unit tests):
    4.66 -run.jvmargs=
    4.67 -run.test.classpath=\
    4.68 -    ${javac.test.classpath}:\
    4.69 -    ${build.test.classes.dir}
    4.70 -src.dir=src
    4.71 -test.src.dir=test
     5.1 --- a/task4/solution02/nbproject/project.xml	Fri Oct 17 17:40:14 2008 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,16 +0,0 @@
     5.4 -<?xml version="1.0" encoding="UTF-8"?>
     5.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
     5.6 -    <type>org.netbeans.modules.java.j2seproject</type>
     5.7 -    <configuration>
     5.8 -        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
     5.9 -            <name>Currency Convertor Solution 02</name>
    5.10 -            <minimum-ant-version>1.6.5</minimum-ant-version>
    5.11 -            <source-roots>
    5.12 -                <root id="src.dir"/>
    5.13 -            </source-roots>
    5.14 -            <test-roots>
    5.15 -                <root id="test.src.dir"/>
    5.16 -            </test-roots>
    5.17 -        </data>
    5.18 -    </configuration>
    5.19 -</project>
     6.1 --- a/task4/solution02/src/org/apidesign/apifest08/currency/CompositeConvertor.java	Fri Oct 17 17:40:14 2008 +0200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,75 +0,0 @@
     6.4 -package org.apidesign.apifest08.currency;
     6.5 -
     6.6 -import java.io.Serializable;
     6.7 -import java.util.Arrays;
     6.8 -import java.util.Currency;
     6.9 -
    6.10 -/**
    6.11 - * Convertor that is composed from other convertors. 
    6.12 - * @author lukas
    6.13 - *
    6.14 - */
    6.15 -class CompositeConvertor implements ExtendedConvertor, Serializable {
    6.16 -
    6.17 -	private static final long serialVersionUID = -2702026568249130055L;
    6.18 -	
    6.19 -	private final ExtendedConvertor[] convertors;
    6.20 -
    6.21 -
    6.22 -	public CompositeConvertor(ExtendedConvertor... convertors) {
    6.23 -		this.convertors = convertors.clone();
    6.24 -		for (ExtendedConvertor convertor: this.convertors)
    6.25 -		{
    6.26 -			if (convertor==null)
    6.27 -			{
    6.28 -				throw new NullPointerException("One of the convertors to be merged is null");
    6.29 -			}
    6.30 -		}
    6.31 -	}
    6.32 -
    6.33 -	/**
    6.34 -	 * Returns true if the composite contains convertor that supports given conversion.
    6.35 -	 */
    6.36 -	public boolean isConversionSupported(Currency from, Currency to) {
    6.37 -		return findConvertorFor(from, to)!=null;
    6.38 -	}
    6.39 -
    6.40 -
    6.41 -	/**
    6.42 -	 * If the composite contains convertor that supports given conversion, delegates to its convert method.
    6.43 -	 * Throws {@link IllegalArgumentException} convertor supporting given conversion is not found. 
    6.44 -	 */
    6.45 -	public Money convert(Money amount, Currency destinationCurrency) throws IllegalArgumentException {
    6.46 -		ExtendedConvertor convertor = findConvertorFor(amount.getCurrency(), destinationCurrency);
    6.47 -		if (convertor!=null)
    6.48 -		{
    6.49 -			return convertor.convert(amount, destinationCurrency);
    6.50 -		}
    6.51 -		throw new IllegalArgumentException("Conversion not supported. Can not convert to "+destinationCurrency+".");
    6.52 -	}
    6.53 -	
    6.54 -	/**
    6.55 -	 * Finds convertor for given currencies. If not found, returns null. 
    6.56 -	 * @param from
    6.57 -	 * @param to
    6.58 -	 * @return
    6.59 -	 */
    6.60 -	ExtendedConvertor findConvertorFor(Currency from, Currency to) {
    6.61 -		//does linear search, in the future can cache the results.
    6.62 -		for (ExtendedConvertor convertor:convertors)
    6.63 -		{
    6.64 -			if (convertor.isConversionSupported(from, to))
    6.65 -			{
    6.66 -				return convertor;
    6.67 -			}
    6.68 -		}
    6.69 -		return null;
    6.70 -	}
    6.71 -	
    6.72 -
    6.73 -	@Override
    6.74 -	public String toString() {
    6.75 -		return getClass().getName()+" converts "+Arrays.toString(convertors);
    6.76 -	}
    6.77 -
    6.78 -}
     7.1 --- a/task4/solution02/src/org/apidesign/apifest08/currency/Convertor.java	Fri Oct 17 17:40:14 2008 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,18 +0,0 @@
     7.4 -package org.apidesign.apifest08.currency;
     7.5 -
     7.6 -import java.util.Currency;
     7.7 -
     7.8 -
     7.9 -/** 
    7.10 - * Converts currencies. To create an instance call {@link ConvertorFactory#createConvertor(Money, Money)}.
    7.11 - */
    7.12 -public interface Convertor {
    7.13 -	/**
    7.14 -	 * Converts amount to its equivalent in the destination currency. 
    7.15 -	 * @param amount 
    7.16 -	 * @param destinationCurrency
    7.17 -	 * @return
    7.18 -	 * @throws IllegalArgumentException if currency of the amount is not supported or if it is not possible to convert it to the destination currency.
    7.19 -	 */
    7.20 -	public Money convert(Money amount, Currency destinationCurrency) throws IllegalArgumentException;
    7.21 -}
     8.1 --- a/task4/solution02/src/org/apidesign/apifest08/currency/ConvertorFactory.java	Fri Oct 17 17:40:14 2008 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,46 +0,0 @@
     8.4 -package org.apidesign.apifest08.currency;
     8.5 -
     8.6 -
     8.7 -
     8.8 -/**
     8.9 - * Creates {@link Convertor} implementations.
    8.10 - * @author lukas
    8.11 - *
    8.12 - */
    8.13 -public class ConvertorFactory {
    8.14 -	private ConvertorFactory()
    8.15 -	{
    8.16 -		//nothing
    8.17 -	}
    8.18 -		
    8.19 -	/**
    8.20 -	 * Creates {@link Convertor} that converts from sourceEquivalent.currency to destinationEquivalent.currency. 
    8.21 -	 * Exchange rate is set as equivalents. It means if you want to create USD to CZK convertor where USD1 = CZK17 
    8.22 -     * call createConvertor(new MoneyImpl(1, USD), new MoneyImpl(17, CZK)). Convertor created by this method 
    8.23 -     * rounds the result to two decimal places. Convertor created by this method is thread safe.
    8.24 -	 * @param sourceEquivalent
    8.25 -	 * @param destinationEquivalent
    8.26 -	 * @return
    8.27 -	 */
    8.28 -	public static final ExtendedConvertor createConvertor(Money sourceEquivalent, Money destinationEquivalent)
    8.29 -	{
    8.30 -		return mergeConvertors(
    8.31 -				new DefaultConvertor(sourceEquivalent, destinationEquivalent),
    8.32 -				new DefaultConvertor(destinationEquivalent ,sourceEquivalent)
    8.33 -		);
    8.34 -	}
    8.35 -	
    8.36 -	/**
    8.37 -	 * Merges convertors. The resulting convertor has ability to do all conversions that its underlying 
    8.38 -	 * convertors could do. No consistency validation is done, inconsistent input will result in a convertor with
    8.39 -	 * inconsistent behavior. Convertor created by this method is thread safe.
    8.40 -	 * @param convertors
    8.41 -	 * @return
    8.42 -	 */
    8.43 -	public static final ExtendedConvertor mergeConvertors(ExtendedConvertor... convertors)
    8.44 -	{
    8.45 -		return new CompositeConvertor(convertors);
    8.46 -	}
    8.47 -	
    8.48 -
    8.49 -}
     9.1 --- a/task4/solution02/src/org/apidesign/apifest08/currency/DefaultConvertor.java	Fri Oct 17 17:40:14 2008 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,95 +0,0 @@
     9.4 -package org.apidesign.apifest08.currency;
     9.5 -
     9.6 -import java.io.Serializable;
     9.7 -import java.math.BigDecimal;
     9.8 -import java.math.RoundingMode;
     9.9 -import java.util.Currency;
    9.10 -
    9.11 -/**
    9.12 - * Default {@link Convertor} implementation. Exchange rate is stored as equivalents. It means if we have USD to CZK convertor and USD1 = CZK17 
    9.13 - * we store 1 in sourceEquivalent and 17 in destinationEquivalent. This class is immutable.
    9.14 - * @author lukas
    9.15 - *
    9.16 - */
    9.17 -class DefaultConvertor implements ExtendedConvertor, Serializable {
    9.18 -
    9.19 -	private static final long serialVersionUID = 6660014633685135034L;
    9.20 -
    9.21 -	/**
    9.22 -	 * Equivalent in source currency.
    9.23 -	 */
    9.24 -	private final BigDecimal sourceEquivalent;
    9.25 -	
    9.26 -	/**
    9.27 -	 * Equivalent in destination currency.
    9.28 -	 */
    9.29 -	private final BigDecimal destinationEquivalent;
    9.30 -	
    9.31 -	private final Currency sourceCurrency;
    9.32 -	
    9.33 -	private final Currency destinationCurrency;
    9.34 -	
    9.35 -	public DefaultConvertor(Money sourceEquivalent, Money destinationEquivalent) {
    9.36 -		super();
    9.37 -		if (BigDecimal.ZERO.compareTo(sourceEquivalent.getAmount())==0)
    9.38 -		{
    9.39 -			throw new IllegalArgumentException("Source equivalent amount can not be 0.");
    9.40 -		}
    9.41 -		if (BigDecimal.ZERO.compareTo(destinationEquivalent.getAmount())==0)
    9.42 -		{
    9.43 -			throw new IllegalArgumentException("Destination equivalent amount can not be 0.");
    9.44 -		}
    9.45 -		this.sourceEquivalent = sourceEquivalent.getAmount();
    9.46 -		this.destinationEquivalent = destinationEquivalent.getAmount();
    9.47 -		this.sourceCurrency = sourceEquivalent.getCurrency();
    9.48 -		this.destinationCurrency = destinationEquivalent.getCurrency();
    9.49 -	}
    9.50 -	
    9.51 -	public Money convert(Money amount, Currency destinationCurrency) {
    9.52 -		if (amount==null)
    9.53 -		{
    9.54 -			throw new NullPointerException("Money is null");
    9.55 -		}
    9.56 -		if (destinationCurrency==null)
    9.57 -		{
    9.58 -			throw new NullPointerException("destionationCurrency is null");
    9.59 -		}
    9.60 -		if (!amount.getCurrency().equals(getSourceCurrency()))
    9.61 -		{
    9.62 -			throw new IllegalArgumentException("Can not convert from "+amount.getCurrency()+". Converts between "+getSourceCurrency()+" and "+getDestinationCurrency());
    9.63 -		}
    9.64 -		if (!getDestinationCurrency().equals(destinationCurrency))
    9.65 -		{
    9.66 -			throw new IllegalArgumentException("Can not convert to "+destinationCurrency+". Converts between "+getSourceCurrency()+" and "+getDestinationCurrency());
    9.67 -		}
    9.68 -		BigDecimal sourceAmount = amount.getAmount();
    9.69 -		BigDecimal destinationAmount = sourceAmount.multiply(destinationEquivalent).divide(sourceEquivalent, 2, RoundingMode.HALF_UP);
    9.70 -		return new MoneyImpl(destinationAmount, getDestinationCurrency());
    9.71 -	}
    9.72 -	
    9.73 -	public boolean isConversionSupported(Currency from, Currency to) {
    9.74 -		return sourceCurrency.equals(from) && destinationCurrency.equals(to);
    9.75 -	}
    9.76 -
    9.77 -	public BigDecimal getSourceEquivalent() {
    9.78 -		return sourceEquivalent;
    9.79 -	}
    9.80 -
    9.81 -	public BigDecimal getDestinationEquivalent() {
    9.82 -		return destinationEquivalent;
    9.83 -	}
    9.84 -
    9.85 -	public Currency getSourceCurrency() {
    9.86 -		return sourceCurrency;
    9.87 -	}
    9.88 -
    9.89 -	public Currency getDestinationCurrency() {
    9.90 -		return destinationCurrency;
    9.91 -	}
    9.92 -	
    9.93 -	@Override
    9.94 -	public String toString() {
    9.95 -		return getClass().getName()+" converts "+getSourceCurrency()+" to "+getDestinationCurrency()+" "
    9.96 -			+getSourceCurrency()+getSourceEquivalent()+"="+getDestinationCurrency()+getDestinationEquivalent();
    9.97 -	}
    9.98 -}
    10.1 --- a/task4/solution02/src/org/apidesign/apifest08/currency/ExtendedConvertor.java	Fri Oct 17 17:40:14 2008 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,18 +0,0 @@
    10.4 -package org.apidesign.apifest08.currency;
    10.5 -
    10.6 -import java.util.Currency;
    10.7 -
    10.8 -/**
    10.9 - * Extended convertor interface. 
   10.10 - * @author lukas
   10.11 - *
   10.12 - */
   10.13 -public interface ExtendedConvertor extends Convertor {
   10.14 -	/**
   10.15 -	 * Returns true if given conversion is supported.
   10.16 -	 * @param from
   10.17 -	 * @param to
   10.18 -	 * @return
   10.19 -	 */
   10.20 -	public boolean isConversionSupported(Currency from, Currency to);
   10.21 -}
    11.1 --- a/task4/solution02/src/org/apidesign/apifest08/currency/Money.java	Fri Oct 17 17:40:14 2008 +0200
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,29 +0,0 @@
    11.4 -package org.apidesign.apifest08.currency;
    11.5 -
    11.6 -import java.math.BigDecimal;
    11.7 -import java.util.Currency;
    11.8 -
    11.9 -/**
   11.10 - * Money representation. Default implementation {@link MoneyImpl} is provided. This interface can
   11.11 - * be implemented by a DTO used in client application.
   11.12 - * @author lukas
   11.13 - *
   11.14 - */
   11.15 -/*
   11.16 - * Whether we need such interface depends on the context. I can imagine than in a desktop application this interface 
   11.17 - * would be useless, Money could be a class. In J2EE environment it can be useful.
   11.18 - */
   11.19 -public interface Money {
   11.20 -
   11.21 -	/**
   11.22 -	 * Returns amount.
   11.23 -	 * @return
   11.24 -	 */
   11.25 -	public BigDecimal getAmount();
   11.26 -
   11.27 -	/**
   11.28 -	 * Returns currency.
   11.29 -	 */
   11.30 -	public Currency getCurrency();
   11.31 -
   11.32 -}
   11.33 \ No newline at end of file
    12.1 --- a/task4/solution02/src/org/apidesign/apifest08/currency/MoneyImpl.java	Fri Oct 17 17:40:14 2008 +0200
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,121 +0,0 @@
    12.4 -package org.apidesign.apifest08.currency;
    12.5 -
    12.6 -import java.io.Serializable;
    12.7 -import java.math.BigDecimal;
    12.8 -import java.util.Currency;
    12.9 -
   12.10 -/**
   12.11 - * Default implementation of {@link Money} interface. This class is immutable.
   12.12 - * @author lukas
   12.13 - *
   12.14 - */
   12.15 -public final class MoneyImpl implements Serializable, Money{
   12.16 -	private static final long serialVersionUID = -6091808475616516136L;
   12.17 -
   12.18 -	private final BigDecimal amount;
   12.19 -	
   12.20 -	private final Currency currency;
   12.21 -	
   12.22 -	public MoneyImpl(BigDecimal amount, Currency currency) {
   12.23 -		if (amount==null) throw new NullPointerException("Amount is null");
   12.24 -		if (currency==null) throw new NullPointerException("Currency is null"+currency);
   12.25 -		this.amount = amount;
   12.26 -		this.currency = currency;
   12.27 -	}
   12.28 -	
   12.29 -	
   12.30 -	
   12.31 -	public MoneyImpl(long amount, Currency currency) {
   12.32 -		this(BigDecimal.valueOf(amount), currency);
   12.33 -	}
   12.34 -	
   12.35 -	public MoneyImpl(double amount, Currency currency) {
   12.36 -		this(BigDecimal.valueOf(amount), currency);
   12.37 -	}
   12.38 -	
   12.39 -	/**
   12.40 -	 * Factory method.
   12.41 -	 * @param amount
   12.42 -	 * @param currency
   12.43 -	 * @return
   12.44 -	 */
   12.45 -	public static final Money money(BigDecimal amount, Currency currency)
   12.46 -	{
   12.47 -		return new MoneyImpl(amount, currency);
   12.48 -	}
   12.49 -	/**
   12.50 -	 * Factory method.
   12.51 -	 * @param amount
   12.52 -	 * @param currency
   12.53 -	 * @return
   12.54 -	 */
   12.55 -	public static final Money money(long amount, Currency currency)
   12.56 -	{
   12.57 -		return new MoneyImpl(amount, currency);
   12.58 -	}
   12.59 -	/**
   12.60 -	 * Factory method.
   12.61 -	 * @param amount
   12.62 -	 * @param currency
   12.63 -	 * @return
   12.64 -	 */
   12.65 -	public static final Money money(double amount, Currency currency)
   12.66 -	{
   12.67 -		return new MoneyImpl(amount, currency);
   12.68 -	}
   12.69 -
   12.70 -	/**
   12.71 -	 * Returns amount.
   12.72 -	 * @return
   12.73 -	 */
   12.74 -	public BigDecimal getAmount() {
   12.75 -		return amount;
   12.76 -	}
   12.77 -	
   12.78 -	/**
   12.79 -	 * Returns currency.
   12.80 -	 */
   12.81 -	public Currency getCurrency() {
   12.82 -		return currency;
   12.83 -	}
   12.84 -
   12.85 -	@Override
   12.86 -	public int hashCode() {
   12.87 -		final int prime = 31;
   12.88 -		int result = 1;
   12.89 -		result = prime * result + ((amount == null) ? 0 : amount.hashCode());
   12.90 -		result = prime * result
   12.91 -				+ ((currency == null) ? 0 : currency.hashCode());
   12.92 -		return result;
   12.93 -	}
   12.94 -
   12.95 -	@Override
   12.96 -	public boolean equals(Object obj) {
   12.97 -		if (this == obj)
   12.98 -			return true;
   12.99 -		if (obj == null)
  12.100 -			return false;
  12.101 -		if (!(obj instanceof MoneyImpl))
  12.102 -			return false;
  12.103 -		MoneyImpl other = (MoneyImpl) obj;
  12.104 -		if (amount == null) {
  12.105 -			if (other.amount != null)
  12.106 -				return false;
  12.107 -		} else if (amount.compareTo(other.amount)!=0)
  12.108 -			return false;
  12.109 -		if (currency == null) {
  12.110 -			if (other.currency != null)
  12.111 -				return false;
  12.112 -		} else if (!currency.equals(other.currency))
  12.113 -			return false;
  12.114 -		return true;
  12.115 -	}
  12.116 -	
  12.117 -	@Override
  12.118 -	public String toString() {
  12.119 -		return getClass().getName()+"["+currency+amount+"]";
  12.120 -	}
  12.121 -
  12.122 -	
  12.123 -	
  12.124 -}
    13.1 --- a/task4/solution02/test/org/apidesign/apifest08/currency/CompositeConvertorTest.java	Fri Oct 17 17:40:14 2008 +0200
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,56 +0,0 @@
    13.4 -package org.apidesign.apifest08.currency;
    13.5 -
    13.6 -import static junit.framework.Assert.assertEquals;
    13.7 -import static junit.framework.Assert.assertFalse;
    13.8 -import static junit.framework.Assert.assertTrue;
    13.9 -import static junit.framework.Assert.fail;
   13.10 -import static org.apidesign.apifest08.test.Task1Test.CZK;
   13.11 -import static org.apidesign.apifest08.test.Task1Test.SKK;
   13.12 -import static org.apidesign.apifest08.test.Task1Test.USD;
   13.13 -
   13.14 -import org.junit.Test;
   13.15 -
   13.16 -public class CompositeConvertorTest {
   13.17 -	private static final ExtendedConvertor USD_CZK_CONVERTOR = ConvertorFactory.createConvertor(new MoneyImpl(1,USD), new MoneyImpl(17,CZK));
   13.18 -	private static final ExtendedConvertor SKK_CZK_CONVERTOR = ConvertorFactory.createConvertor(new MoneyImpl(100,SKK), new MoneyImpl(80,CZK));
   13.19 -
   13.20 -	@Test
   13.21 -	public void testCompose()
   13.22 -	{
   13.23 -		ExtendedConvertor convertor = new CompositeConvertor(USD_CZK_CONVERTOR, SKK_CZK_CONVERTOR);
   13.24 -		assertTrue(convertor.isConversionSupported(CZK, SKK));
   13.25 -		assertTrue(convertor.isConversionSupported(CZK, USD));
   13.26 -		assertFalse(convertor.isConversionSupported(SKK, USD));
   13.27 -		assertEquals(new MoneyImpl(10,SKK), convertor.convert(new MoneyImpl(8,CZK), SKK));
   13.28 -		assertEquals(new MoneyImpl(2,USD), convertor.convert(new MoneyImpl(34,CZK), USD));
   13.29 -		try
   13.30 -		{
   13.31 -			convertor.convert(new MoneyImpl(34,SKK), USD);
   13.32 -			fail("Exception expected");
   13.33 -		}
   13.34 -		catch(IllegalArgumentException e)
   13.35 -		{
   13.36 -			assertTrue("Ok", true);
   13.37 -		}
   13.38 -	}
   13.39 -	@Test
   13.40 -	public void testEmpty()
   13.41 -	{
   13.42 -		ExtendedConvertor convertor = new CompositeConvertor();
   13.43 -		assertFalse(convertor.isConversionSupported(SKK, USD));
   13.44 -		try
   13.45 -		{
   13.46 -			convertor.convert(new MoneyImpl(34,SKK), USD);
   13.47 -			fail("Exception expected");
   13.48 -		}
   13.49 -		catch(IllegalArgumentException e)
   13.50 -		{
   13.51 -			assertTrue("Ok", true);
   13.52 -		}
   13.53 -	}
   13.54 -	@Test(expected=NullPointerException.class)
   13.55 -	public void testCreateNull()
   13.56 -	{
   13.57 -		new CompositeConvertor(USD_CZK_CONVERTOR, null);
   13.58 -	}
   13.59 -}
    14.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/ConvertorFactoryTest.java	Fri Oct 17 17:40:14 2008 +0200
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,52 +0,0 @@
    14.4 -package org.apidesign.apifest08.test;
    14.5 -
    14.6 -import static junit.framework.Assert.assertNotNull;
    14.7 -import static org.apidesign.apifest08.test.Task1Test.CZK;
    14.8 -import static org.apidesign.apifest08.test.Task1Test.USD;
    14.9 -import static org.junit.Assert.assertEquals;
   14.10 -import static org.junit.Assert.assertTrue;
   14.11 -import static org.junit.Assert.fail;
   14.12 -
   14.13 -import org.apidesign.apifest08.currency.Convertor;
   14.14 -import org.apidesign.apifest08.currency.ConvertorFactory;
   14.15 -import org.apidesign.apifest08.currency.MoneyImpl;
   14.16 -import org.junit.Test;
   14.17 -
   14.18 -
   14.19 -public class ConvertorFactoryTest {
   14.20 -	@Test(expected=NullPointerException.class)
   14.21 -	public void testNullSource()
   14.22 -	{
   14.23 -		ConvertorFactory.createConvertor(null, new MoneyImpl(1,USD));
   14.24 -	}
   14.25 -	@Test(expected=NullPointerException.class)
   14.26 -	public void testNullDestination()
   14.27 -	{
   14.28 -		ConvertorFactory.createConvertor(new MoneyImpl(17,CZK), null);
   14.29 -	}
   14.30 -	@Test
   14.31 -	public void testOk()
   14.32 -	{
   14.33 -		assertNotNull(ConvertorFactory.createConvertor(new MoneyImpl(17,CZK),  new MoneyImpl(1,USD)));
   14.34 -	}
   14.35 -	@Test
   14.36 -	public void testOkDecimalRate()
   14.37 -	{
   14.38 -		Convertor c = ConvertorFactory.createConvertor(new MoneyImpl(1,CZK),  new MoneyImpl(1d/17d,USD));
   14.39 -		assertNotNull(c);
   14.40 -		assertEquals(new MoneyImpl(17,CZK),c.convert(new MoneyImpl(1,USD), CZK));
   14.41 -	}
   14.42 -	@Test
   14.43 -	public void testZeroEquivalentRate()
   14.44 -	{
   14.45 -		try
   14.46 -		{
   14.47 -			ConvertorFactory.createConvertor(new MoneyImpl(1,CZK),  new MoneyImpl(0,USD));
   14.48 -			fail("Exception expected");
   14.49 -		}
   14.50 -		catch(IllegalArgumentException e)
   14.51 -		{
   14.52 -			assertTrue("OK",true);
   14.53 -		}
   14.54 -	}
   14.55 -}
    15.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/ConvertorTest.java	Fri Oct 17 17:40:14 2008 +0200
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,44 +0,0 @@
    15.4 -package org.apidesign.apifest08.test;
    15.5 -
    15.6 -import static junit.framework.Assert.assertEquals;
    15.7 -import static junit.framework.Assert.assertFalse;
    15.8 -import static junit.framework.Assert.assertTrue;
    15.9 -import static org.apidesign.apifest08.test.Task1Test.CZK;
   15.10 -import static org.apidesign.apifest08.test.Task1Test.SKK;
   15.11 -import static org.apidesign.apifest08.test.Task1Test.USD;
   15.12 -
   15.13 -import java.math.BigDecimal;
   15.14 -
   15.15 -import org.apidesign.apifest08.currency.ConvertorFactory;
   15.16 -import org.apidesign.apifest08.currency.ExtendedConvertor;
   15.17 -import org.apidesign.apifest08.currency.Money;
   15.18 -import org.apidesign.apifest08.currency.MoneyImpl;
   15.19 -import org.junit.Test;
   15.20 -
   15.21 -
   15.22 -public class ConvertorTest {
   15.23 -
   15.24 -	private static final ExtendedConvertor CZK_TO_USD_CONVERTOR = ConvertorFactory.createConvertor(new MoneyImpl(17,CZK), new MoneyImpl(1,USD));
   15.25 -	@Test
   15.26 -	public void testConvertSmall()
   15.27 -	{
   15.28 -		Money converted = CZK_TO_USD_CONVERTOR.convert(new MoneyImpl(0.17,CZK),USD);
   15.29 -		assertEquals(new MoneyImpl(new BigDecimal("0.01"),USD),converted);
   15.30 -		assertEquals(USD,converted.getCurrency());
   15.31 -	}
   15.32 -	@Test
   15.33 -	public void testConvertSmallReverse()
   15.34 -	{
   15.35 -		Money converted = CZK_TO_USD_CONVERTOR.convert(new MoneyImpl(0.01,USD),CZK);
   15.36 -		assertEquals(new MoneyImpl(new BigDecimal("0.17"),CZK),converted);
   15.37 -	}
   15.38 -	@Test
   15.39 -	public void testSupports()
   15.40 -	{
   15.41 -		assertTrue(CZK_TO_USD_CONVERTOR.isConversionSupported(USD,CZK));
   15.42 -		assertTrue(CZK_TO_USD_CONVERTOR.isConversionSupported(CZK,USD));
   15.43 -		assertFalse(CZK_TO_USD_CONVERTOR.isConversionSupported(CZK,CZK));
   15.44 -		assertFalse(CZK_TO_USD_CONVERTOR.isConversionSupported(CZK,SKK));
   15.45 -		
   15.46 -	}
   15.47 -}
    16.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/MoneyTest.java	Fri Oct 17 17:40:14 2008 +0200
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,24 +0,0 @@
    16.4 -package org.apidesign.apifest08.test;
    16.5 -
    16.6 -import static junit.framework.Assert.assertEquals;
    16.7 -import static org.apidesign.apifest08.test.Task1Test.CZK;
    16.8 -
    16.9 -import java.math.BigDecimal;
   16.10 -
   16.11 -import org.apidesign.apifest08.currency.MoneyImpl;
   16.12 -import org.junit.Test;
   16.13 -
   16.14 -public class MoneyTest {
   16.15 -	@Test(expected=NullPointerException.class)
   16.16 -	public void testNullAmount(){
   16.17 -		new MoneyImpl(null,CZK);
   16.18 -	}
   16.19 -	@Test(expected=NullPointerException.class)
   16.20 -	public void testNullCurrency(){
   16.21 -		new MoneyImpl(1,null);
   16.22 -	}
   16.23 -	@Test
   16.24 -	public void testOk(){
   16.25 -		assertEquals(0,new MoneyImpl(123,CZK).getAmount().compareTo(new BigDecimal("123")));
   16.26 -	}
   16.27 -}
    17.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/OnlineConvertor.java	Fri Oct 17 17:40:14 2008 +0200
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,54 +0,0 @@
    17.4 -package org.apidesign.apifest08.test;
    17.5 -
    17.6 -import java.math.BigDecimal;
    17.7 -import java.util.Currency;
    17.8 -
    17.9 -import org.apidesign.apifest08.currency.ConvertorFactory;
   17.10 -import org.apidesign.apifest08.currency.ExtendedConvertor;
   17.11 -import org.apidesign.apifest08.currency.Money;
   17.12 -import org.apidesign.apifest08.currency.MoneyImpl;
   17.13 -
   17.14 -/**
   17.15 - * Third party implementation of the convertor. IT IS NOT THREAD SAFE.
   17.16 - * @author lukas
   17.17 - *
   17.18 - */
   17.19 -class OnlineConvertor implements ExtendedConvertor {
   17.20 -	
   17.21 -	private static final BigDecimal LOWER_LIMIT = BigDecimal.valueOf(15);
   17.22 -	private static final BigDecimal HIGHER_LIMIT = BigDecimal.valueOf(16);
   17.23 -	
   17.24 -	private static final Currency USD = Currency.getInstance("USD");
   17.25 -	private static final Currency CZK = Currency.getInstance("CZK");
   17.26 -	private static final MoneyImpl ONE_USD = new MoneyImpl(1,USD);
   17.27 -	
   17.28 -	private ExtendedConvertor wrappedConvertor = ConvertorFactory.createConvertor(ONE_USD, new MoneyImpl(16, CZK));
   17.29 -	
   17.30 -	private BigDecimal increment = new BigDecimal("-0.01");
   17.31 -	
   17.32 -	public boolean isConversionSupported(Currency from, Currency to) {
   17.33 -		return wrappedConvertor.isConversionSupported(from, to);
   17.34 -	}
   17.35 -
   17.36 -	public Money convert(Money amount, Currency destinationCurrency)
   17.37 -			throws IllegalArgumentException {
   17.38 -		Money result = wrappedConvertor.convert(amount, destinationCurrency);
   17.39 -		updateConvertor();
   17.40 -		return result;
   17.41 -	}
   17.42 -
   17.43 -	/**
   17.44 -	 * Prepares convertor for the next conversion.
   17.45 -	 */
   17.46 -	private void updateConvertor() {
   17.47 -		BigDecimal currentRate = wrappedConvertor.convert(ONE_USD, CZK).getAmount();
   17.48 -		BigDecimal newRate = currentRate.add(increment);
   17.49 -		
   17.50 -		if (LOWER_LIMIT.compareTo(newRate)==0 || HIGHER_LIMIT.compareTo(newRate)==0)
   17.51 -		{
   17.52 -			increment = increment.negate();
   17.53 -		}
   17.54 -		wrappedConvertor = ConvertorFactory.createConvertor(ONE_USD, new MoneyImpl(newRate, CZK));
   17.55 -	}
   17.56 -
   17.57 -}
    18.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/OnlineConvertorTest.java	Fri Oct 17 17:40:14 2008 +0200
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,44 +0,0 @@
    18.4 -package org.apidesign.apifest08.test;
    18.5 -import static junit.framework.Assert.assertEquals;
    18.6 -import static org.apidesign.apifest08.currency.MoneyImpl.money;
    18.7 -import static org.apidesign.apifest08.test.Task1Test.CZK;
    18.8 -import static org.apidesign.apifest08.test.Task1Test.USD;
    18.9 -
   18.10 -import java.math.BigDecimal;
   18.11 -
   18.12 -import org.apidesign.apifest08.currency.Convertor;
   18.13 -import org.apidesign.apifest08.currency.Money;
   18.14 -import org.junit.Test;
   18.15 -
   18.16 -public class OnlineConvertorTest {
   18.17 -	private static final Money ONE_USD = money(1, USD);
   18.18 -
   18.19 -	@Test
   18.20 -	public void testBounce()
   18.21 -	{
   18.22 -		Convertor c = Task3Test.createOnlineCZKUSDConvertor();
   18.23 -		
   18.24 -		doBounceTest(c);
   18.25 -		doBounceTest(c);
   18.26 -	
   18.27 -	}
   18.28 -
   18.29 -	private void doBounceTest(Convertor c) {
   18.30 -		BigDecimal expectedRate = new BigDecimal(16);
   18.31 -		BigDecimal increment = new BigDecimal("0.01");
   18.32 -		
   18.33 -		for (int i=0;i<100;i++)
   18.34 -		{
   18.35 -			assertEquals(money(expectedRate,CZK), c.convert(ONE_USD, CZK));
   18.36 -			expectedRate = expectedRate.subtract(increment);
   18.37 -		}
   18.38 -		
   18.39 -		assertEquals(money(15,CZK), c.convert(ONE_USD, CZK));
   18.40 -		
   18.41 -		for (int i=0;i<99;i++)
   18.42 -		{
   18.43 -			expectedRate = expectedRate.add(increment);
   18.44 -			assertEquals(money(expectedRate,CZK), c.convert(ONE_USD, CZK));
   18.45 -		}
   18.46 -	}
   18.47 -}
    19.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/Task1Test.java	Fri Oct 17 17:40:14 2008 +0200
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,160 +0,0 @@
    19.4 -package org.apidesign.apifest08.test;
    19.5 -
    19.6 -import java.util.Currency;
    19.7 -
    19.8 -import junit.framework.TestCase;
    19.9 -
   19.10 -import org.apidesign.apifest08.currency.Convertor;
   19.11 -import org.apidesign.apifest08.currency.ConvertorFactory;
   19.12 -import org.apidesign.apifest08.currency.MoneyImpl;
   19.13 -
   19.14 -/** Finish the Convertor API, and then write bodies of methods inside
   19.15 - * of this class to match the given tasks. To fullfil your task, use the
   19.16 - * API define in the <code>org.apidesign.apifest08.currency</code> package.
   19.17 - * Do not you reflection, or other hacks as your code
   19.18 - * shall run without any runtime permissions.
   19.19 - */
   19.20 -public class Task1Test extends TestCase {
   19.21 -	
   19.22 -	public static final Currency USD = Currency.getInstance("USD");
   19.23 -	public static final Currency CZK = Currency.getInstance("CZK");
   19.24 -	public static final Currency SKK = Currency.getInstance("SKK");
   19.25 -	
   19.26 -    public Task1Test(String testName) {
   19.27 -        super(testName);
   19.28 -    }
   19.29 -
   19.30 -    @Override
   19.31 -    protected void setUp() throws Exception {
   19.32 -    }
   19.33 -
   19.34 -    @Override
   19.35 -    protected void tearDown() throws Exception {
   19.36 -    }
   19.37 -
   19.38 -    //
   19.39 -    // Imagine that there are three parts of the whole system:
   19.40 -    // 1. there is someone who knows the current exchange rate
   19.41 -    // 2. there is someone who wants to do the conversion
   19.42 -    // 3. there is the API between 1. and 2. which allows them to communicate
   19.43 -    // Please design such API
   19.44 -    //
   19.45 -
   19.46 -    /** Create convertor that understands two currencies, CZK and
   19.47 -     *  USD. Make 1 USD == 17 CZK. This is a method provided for #1 group -
   19.48 -     *  e.g. those that know the exchange rate. They somehow need to create
   19.49 -     *  the objects from the API and tell them the exchange rate. The API itself
   19.50 -     *  knows nothing about any rates, before the createCZKtoUSD method is called.
   19.51 -     *
   19.52 -     * Creation of the convertor shall not require subclassing of any class
   19.53 -     * or interface on the client side.
   19.54 -     *
   19.55 -     * @return prepared convertor ready for converting USD to CZK and CZK to USD
   19.56 -     */
   19.57 -    public static Convertor createCZKtoUSD() {
   19.58 -    	return ConvertorFactory.createConvertor(new MoneyImpl(17,CZK), new MoneyImpl(1,USD));
   19.59 -    }
   19.60 -
   19.61 -    /** Create convertor that understands two currencies, CZK and
   19.62 -     *  SKK. Make 100 SKK == 80 CZK. Again this is method for the #1 group -
   19.63 -     *  it knows the exchange rate, and needs to use the API to create objects
   19.64 -     *  with the exchange rate. Anyone shall be ready to call this method without
   19.65 -     *  any other method being called previously. The API itself shall know
   19.66 -     *  nothing about any rates, before this method is called.
   19.67 -     *
   19.68 -     * Creation of the convertor shall not require subclassing of any class
   19.69 -     * or interface on the client side.
   19.70 -     * 
   19.71 -     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
   19.72 -     */
   19.73 -    public static Convertor createSKKtoCZK() {
   19.74 -    	return ConvertorFactory.createConvertor(new MoneyImpl(100,SKK), new MoneyImpl(80,CZK));
   19.75 -    }
   19.76 -
   19.77 -    //
   19.78 -    // now the methods for group #2 follow:
   19.79 -    // this group knows nothing about exchange rates, but knows how to use
   19.80 -    // the API to do conversions. It somehow (by calling one of the factory
   19.81 -    // methods) gets objects from the API and uses them to do the conversions.
   19.82 -    //
   19.83 -    
   19.84 -    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
   19.85 -     * with it.
   19.86 -     */
   19.87 -    public void testCurrencyCZKUSD() throws Exception {
   19.88 -    	Convertor c = createCZKtoUSD();
   19.89 -        // convert $5 to CZK using c:
   19.90 -        assertEquals("Result is 85 CZK",new MoneyImpl(85,CZK), c.convert(new MoneyImpl(5,USD),CZK));
   19.91 -
   19.92 -        // convert $8 to CZK
   19.93 -        assertEquals("Result is 136 CZK",new MoneyImpl(136,CZK), c.convert(new MoneyImpl(8,USD),CZK));
   19.94 -
   19.95 -        // convert 1003CZK to USD
   19.96 -        assertEquals("Result is 59 USD", new MoneyImpl(59,USD), c.convert(new MoneyImpl(1003,CZK),USD));
   19.97 -        
   19.98 -    }
   19.99 -
  19.100 -    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
  19.101 -     * with it.
  19.102 -     */
  19.103 -    public void testCurrencySKKCZK() throws Exception {
  19.104 -        Convertor c = createSKKtoCZK();
  19.105 -        // convert 16CZK using c:
  19.106 -        assertEquals("Result is 20 SKK", new MoneyImpl(20,SKK), c.convert(new MoneyImpl(16,CZK),SKK));
  19.107 -
  19.108 -        // convert 500SKK to CZK
  19.109 -        assertEquals("Result is 400 CZK", new MoneyImpl(400,CZK), c.convert(new MoneyImpl(500,SKK),CZK));
  19.110 -    }
  19.111 -
  19.112 -    /** Verify that the CZK to USD convertor knows nothing about SKK.
  19.113 -     */
  19.114 -    public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
  19.115 -        Convertor c = createCZKtoUSD();
  19.116 -        // convert $5 to SKK, the API shall say this is not possible
  19.117 -        try
  19.118 -        {
  19.119 -        	c.convert(new MoneyImpl(5, USD), SKK);
  19.120 -        	fail("Exception expected");
  19.121 -        }
  19.122 -        catch(IllegalArgumentException e)
  19.123 -        {
  19.124 -        	assertTrue("Ok",true);
  19.125 -        }
  19.126 -        // convert 500 SKK to CZK, the API shall say this is not possible
  19.127 -        try
  19.128 -        {
  19.129 -        	c.convert(new MoneyImpl(500, SKK), CZK);
  19.130 -        	fail("Exception expected");
  19.131 -        }
  19.132 -        catch(IllegalArgumentException e)
  19.133 -        {
  19.134 -        	assertTrue("Ok",true);
  19.135 -        }
  19.136 -    }
  19.137 -
  19.138 -    /** Verify that the CZK to SKK convertor knows nothing about USD.
  19.139 -     */
  19.140 -    public void testCannotConvertToUSDwithCZKSKKConvertor() throws Exception {
  19.141 -        Convertor c = createSKKtoCZK();
  19.142 -        // convert $5 to SKK, the API shall say this is not possible
  19.143 -        try
  19.144 -        {
  19.145 -        	c.convert(new MoneyImpl(5, USD), SKK);
  19.146 -        	fail("Exception expected");
  19.147 -        }
  19.148 -        catch(IllegalArgumentException e)
  19.149 -        {
  19.150 -        	assertTrue("Ok",true);
  19.151 -        }
  19.152 -        // convert 500 CZK to USD, the API shall say this is not possible
  19.153 -        try
  19.154 -        {
  19.155 -        	c.convert(new MoneyImpl(500, CZK), USD);
  19.156 -        	fail("Exception expected");
  19.157 -        }
  19.158 -        catch(IllegalArgumentException e)
  19.159 -        {
  19.160 -        	assertTrue("Ok",true);
  19.161 -        }
  19.162 -    }
  19.163 -}
    20.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/Task2Test.java	Fri Oct 17 17:40:14 2008 +0200
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,119 +0,0 @@
    20.4 -package org.apidesign.apifest08.test;
    20.5 -
    20.6 -import static org.apidesign.apifest08.currency.ConvertorFactory.createConvertor;
    20.7 -import static org.apidesign.apifest08.currency.ConvertorFactory.mergeConvertors;
    20.8 -import static org.apidesign.apifest08.currency.MoneyImpl.money;
    20.9 -import static org.apidesign.apifest08.test.Task1Test.CZK;
   20.10 -import static org.apidesign.apifest08.test.Task1Test.SKK;
   20.11 -import static org.apidesign.apifest08.test.Task1Test.USD;
   20.12 -import junit.framework.TestCase;
   20.13 -
   20.14 -import org.apidesign.apifest08.currency.Convertor;
   20.15 -import org.apidesign.apifest08.currency.ExtendedConvertor;
   20.16 -
   20.17 -/** There are many currencies around the world and many banks manipulate
   20.18 - * with more than one or two at the same time. As banks are usually the
   20.19 - * best paying clients, which is true even in case of your Convertor API,
   20.20 - * it is reasonable to listen to their requests.
   20.21 - * <p>
   20.22 - * The quest for today is to enhance your existing convertor API to hold
   20.23 - * information about many currencies and allow conversions between any of them.
   20.24 - * Also, as conversion rates for diferent currencies usually arise from various
   20.25 - * bank departments, there is another important need. There is a need to
   20.26 - * compose two convertors into one by merging all the information about
   20.27 - * currencies they know about.
   20.28 - */
   20.29 -public class Task2Test extends TestCase {
   20.30 -    public Task2Test(String testName) {
   20.31 -        super(testName);
   20.32 -    }
   20.33 -
   20.34 -    @Override
   20.35 -    protected void setUp() throws Exception {
   20.36 -    }
   20.37 -
   20.38 -    @Override
   20.39 -    protected void tearDown() throws Exception {
   20.40 -    }
   20.41 -
   20.42 -    // As in Task1Test, keep in mind, that there are three parts
   20.43 -    // of the whole system:
   20.44 -    // 1. there is someone who knows the current exchange rate
   20.45 -    // 2. there is someone who wants to do the conversion
   20.46 -    // 3. there is the API between 1. and 2. which allows them to communicate
   20.47 -    // 
   20.48 -    // Please backward compatibly enhance your existing API to support following
   20.49 -    // usecases:
   20.50 -    //
   20.51 -    
   20.52 -    /** Create convertor that understands two currencies, CZK and
   20.53 -     *  SKK. Make 100 SKK == 75 CZK. This is method for the group of users that
   20.54 -     *  knows the exchange rate, and needs to use the API to create objects
   20.55 -     *  with the exchange rate. Anyone shall be ready to call this method without
   20.56 -     *  any other method being called previously. The API itself shall know
   20.57 -     *  nothing about any rates, before this method is called.
   20.58 -     */
   20.59 -    public static Convertor createTripleConvertor() {
   20.60 -        // Rates: 1USD = 15CZK
   20.61 -        // Rates: 1USD = 20SKK
   20.62 -        // Rates: 75CZK = 100SKK
   20.63 -	   return mergeConvertors(
   20.64 -			   createConvertor(money(1, USD),  money(15, CZK)),
   20.65 -			   createConvertor(money(1, USD),  money(20, SKK)),
   20.66 -			   createConvertor(money(75, CZK), money(100, SKK))
   20.67 -       );
   20.68 -    }
   20.69 -
   20.70 -    /** Define convertor that understands three currencies. Use it.
   20.71 -     */
   20.72 -    public void testConvertorForUSDandCZKandSKK() throws Exception {
   20.73 -        Convertor c = createTripleConvertor();
   20.74 -
   20.75 -        // convert $5 to CZK using c:
   20.76 -        assertEquals("Result is 75 CZK", money(75, CZK),c.convert(money(5,USD), CZK));
   20.77 -
   20.78 -        // convert $5 to SKK using c:
   20.79 -        assertEquals("Result is 100 SKK", money(100, SKK),c.convert(money(5,USD), SKK));
   20.80 -
   20.81 -        // convert 200SKK to CZK using c:
   20.82 -        assertEquals("Result is 150 CZK", money(150, CZK),c.convert(money(200,SKK), CZK));
   20.83 -
   20.84 -        // convert 200SKK to USK using c:
   20.85 -        assertEquals("Result is 10 USD", money(10, USD),c.convert(money(200,SKK), USD));
   20.86 -    }
   20.87 -
   20.88 -    /** Merge all currency rates of convertor 1 with convertor 2.
   20.89 -     * Implement this using your API, preferably this method just delegates
   20.90 -     * into some API method which does the actual work, without requiring
   20.91 -     * API clients to code anything complex.
   20.92 -     */
   20.93 -    public static Convertor merge(Convertor one, Convertor two) {
   20.94 -        return mergeConvertors((ExtendedConvertor)one, (ExtendedConvertor)two);
   20.95 -    }
   20.96 -
   20.97 -    /** Join the convertors from previous task, Task1Test and show that it
   20.98 -     * can be used to do reasonable conversions.
   20.99 -     */
  20.100 -    public void testConvertorComposition() throws Exception {
  20.101 -        Convertor c = merge(
  20.102 -            Task1Test.createCZKtoUSD(),
  20.103 -            Task1Test.createSKKtoCZK()
  20.104 -        );
  20.105 -
  20.106 -        // convert $5 to CZK using c:
  20.107 -        assertEquals("Result is 85 CZK", money(85, CZK),c.convert(money(5,USD), CZK));
  20.108 -
  20.109 -        // convert $8 to CZK using c:
  20.110 -        assertEquals("Result is 136 CZK", money(136, CZK),c.convert(money(8,USD), CZK));
  20.111 -
  20.112 -        // convert 1003CZK to USD using c:
  20.113 -        assertEquals("Result is 59 USD", money(59, USD),c.convert(money(1003,CZK), USD));
  20.114 -
  20.115 -        // convert 16CZK using c:
  20.116 -        assertEquals("Result is 20 SKK", money(20, SKK),c.convert(money(16,CZK), SKK));
  20.117 -
  20.118 -        // convert 500SKK to CZK using c:
  20.119 -        assertEquals("Result is 400 CZK", money(400, CZK),c.convert(money(500,SKK), CZK));
  20.120 -
  20.121 -    }
  20.122 -}
    21.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/Task3Test.java	Fri Oct 17 17:40:14 2008 +0200
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,100 +0,0 @@
    21.4 -package org.apidesign.apifest08.test;
    21.5 -
    21.6 -import static org.apidesign.apifest08.currency.MoneyImpl.money;
    21.7 -import static org.apidesign.apifest08.test.Task1Test.CZK;
    21.8 -import static org.apidesign.apifest08.test.Task1Test.SKK;
    21.9 -import static org.apidesign.apifest08.test.Task1Test.USD;
   21.10 -import junit.framework.TestCase;
   21.11 -
   21.12 -import org.apidesign.apifest08.currency.Convertor;
   21.13 -
   21.14 -/** The exchange rates are not always the same. They are changing. Day by day,
   21.15 - * hour by hour, minute by minute. For every bank it is important to always
   21.16 - * have the actual exchange rate available in the system. That is why let's
   21.17 - * create a pluggable convertor that will always have up to date value of its
   21.18 - * exchange rate.
   21.19 - * <p>
   21.20 - * The quest for today is to allow 3rd party developer to write a convertor
   21.21 - * that adjusts its exchange rate everytime it is queried. This convertor is
   21.22 - * written by independent vendor, the vendor knows only your Convertor API,
   21.23 - * he does not know how the whole system looks and how the convertor is supposed
   21.24 - * to be used.
   21.25 - */
   21.26 -public class Task3Test extends TestCase {
   21.27 -    public Task3Test(String testName) {
   21.28 -        super(testName);
   21.29 -    }
   21.30 -
   21.31 -    @Override
   21.32 -    protected void setUp() throws Exception {
   21.33 -    }
   21.34 -
   21.35 -    @Override
   21.36 -    protected void tearDown() throws Exception {
   21.37 -    }
   21.38 -
   21.39 -    // Backward compatibly enhance your existing API to support following
   21.40 -    // usecases:
   21.41 -    //
   21.42 -
   21.43 -
   21.44 -    /** Without knowing anything about the surrounding system, write an
   21.45 -     * implementation of convertor that will return different rates everytime
   21.46 -     * it is queried. Convert USD to CZK and vice versa. Start with the rate of
   21.47 -     * 1USD = 16CZK and adjust it in favor of CZK by 0.01 CZK with every query.
   21.48 -     * As soon as you reach 1USD = 15CZK adjust it by 0.01 CZK in favor of USD
   21.49 -     * until you reach 1USD = 16CZK
   21.50 -     *
   21.51 -     * @return new instance of "online" USD and CZK convertor starting with rate 1USD = 16CZK
   21.52 -     */
   21.53 -    public static Convertor createOnlineCZKUSDConvertor() {
   21.54 -        // initial rate: 1USD = 16CZK
   21.55 -        // 2nd query 1USD = 15.99CZK
   21.56 -        // 3rd query 1USD = 15.98CZK
   21.57 -        // until 1USD = 15.00CZK
   21.58 -        // then 1USD = 15.01CZK
   21.59 -        // then 1USD = 15.02CZK
   21.60 -        // and so on and on up to 1USD = 16CZK
   21.61 -        // and then another round to 15, etc.
   21.62 -        return new OnlineConvertor();
   21.63 -    }
   21.64 -
   21.65 -    public void testFewQueriesForOnlineConvertor() {
   21.66 -        Convertor c = createOnlineCZKUSDConvertor();
   21.67 -        doFewQueriesForOnlineConvertor(c);
   21.68 -    }
   21.69 -
   21.70 -    static void doFewQueriesForOnlineConvertor(Convertor c) {
   21.71 -        // convert $5 to CZK using c:
   21.72 -        assertEquals("Result is 80 CZK", money(80,CZK), c.convert(money(5,USD), CZK));
   21.73 -
   21.74 -        // convert $8 to CZK using c:
   21.75 -        assertEquals("Result is 127.92 CZK", money(127.92,CZK), c.convert(money(8,USD), CZK));
   21.76 -
   21.77 -        // convert $1 to CZK using c:
   21.78 -        assertEquals("Result is 15.98 CZK", money(15.98,CZK), c.convert(money(1,USD), CZK));
   21.79 -
   21.80 -        // convert 15.97CZK to USD using c:
   21.81 -        assertEquals("Result is 1 USD", money(1,USD), c.convert(money(15.97,CZK), USD));
   21.82 -        //assertEquals("Result is 1$");
   21.83 -
   21.84 -    }
   21.85 -
   21.86 -    /** Join the convertors and show they behave sane.
   21.87 -     */
   21.88 -    public void testOnlineConvertorComposition() throws Exception {
   21.89 -        
   21.90 -        Convertor c = Task2Test.merge(
   21.91 -            createOnlineCZKUSDConvertor(),
   21.92 -            Task1Test.createSKKtoCZK()
   21.93 -        );
   21.94 -
   21.95 -        // convert 16CZK to SKK using c:
   21.96 -        assertEquals("Result is 20 SKK", money(20,SKK), c.convert(money(16,CZK), SKK));
   21.97 -
   21.98 -        // convert 500SKK to CZK using c:
   21.99 -        assertEquals("Result is 400 CZK", money(400,CZK), c.convert(money(500,SKK), CZK));
  21.100 -
  21.101 -        doFewQueriesForOnlineConvertor(c);
  21.102 -    }
  21.103 -}
    22.1 --- a/task4/solution02/test/org/apidesign/apifest08/test/Task4Test.java	Fri Oct 17 17:40:14 2008 +0200
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,132 +0,0 @@
    22.4 -package org.apidesign.apifest08.test;
    22.5 -
    22.6 -import java.util.Date;
    22.7 -import junit.framework.TestCase;
    22.8 -import org.apidesign.apifest08.currency.Convertor;
    22.9 -
   22.10 -/** The exchange rates are not always the same. They are changing. However
   22.11 - * as in order to predict the future, one needs to understand own past. That is
   22.12 - * why it is important to know the exchange rate as it was at any time during
   22.13 - * the past.
   22.14 - * <p>
   22.15 - * Today's quest is to enhance the convertor API to deal with dates.
   22.16 - * One shall be able to convert a currency at any date. Each currencies rate shall
   22.17 - * be associated with a range between two Date objects. In order
   22.18 - * to keep compatibility with old API that knew nothing about dates, the
   22.19 - * rates associated then are applicable "for eternity". Any use of existing
   22.20 - * convert methods that do not accept a Date argument, uses the current
   22.21 - * System.currentTimeMillis() as default date.
   22.22 - */
   22.23 -public class Task4Test extends TestCase {
   22.24 -    public Task4Test(String testName) {
   22.25 -        super(testName);
   22.26 -    }
   22.27 -
   22.28 -    @Override
   22.29 -    protected void setUp() throws Exception {
   22.30 -    }
   22.31 -
   22.32 -    @Override
   22.33 -    protected void tearDown() throws Exception {
   22.34 -    }
   22.35 -
   22.36 -    // Backward compatibly enhance your existing API to support following
   22.37 -    // usecases:
   22.38 -    //
   22.39 -
   22.40 -    /** Takes a convertor with any rates associated and creates new convertor
   22.41 -     * that returns the same values as the old one for time between from to till.
   22.42 -     * Otherwise it returns no results. This is just a helper method that
   22.43 -     * shall call some real one in the API.
   22.44 -     * 
   22.45 -     * @param old existing convertor
   22.46 -     * @param from initial date (inclusive)
   22.47 -     * @param till final date (exclusive)
   22.48 -     * @return new convertor
   22.49 -     */
   22.50 -    public static Convertor limitTo(Convertor old, Date from, Date till) {
   22.51 -        return null;
   22.52 -    }
   22.53 -
   22.54 -
   22.55 -    public void testCompositionOfLimitedConvertors() throws Exception {
   22.56 -        if (Boolean.getBoolean("ignore.failing")) {
   22.57 -            // implement me! then delete this if statement
   22.58 -            return;
   22.59 -        }
   22.60 -
   22.61 -        Date d1 = null; // 2008-10-01 0:00 GMT
   22.62 -        Date d2 = null; // 2008-10-02 0:00 GMT
   22.63 -        Date d3 = null; // 2008-10-03 0:00 GMT
   22.64 -        
   22.65 -        Convertor c = Task2Test.merge(
   22.66 -            limitTo(Task1Test.createCZKtoUSD(), d1, d2),
   22.67 -            limitTo(Task1Test.createSKKtoCZK(), d2, d3)
   22.68 -        );
   22.69 -
   22.70 -        // convert $5 to CZK using c:
   22.71 -        // cannot convert as no rate is applicable to current date
   22.72 -
   22.73 -        // convert $8 to CZK using c:
   22.74 -        // cannot convert as no rate is applicable to current date
   22.75 -
   22.76 -        // convert 1003CZK to USD using c:
   22.77 -        // cannot convert as no rate is applicable to current date
   22.78 -
   22.79 -        // convert 16CZK using c:
   22.80 -        // cannot convert as no rate is applicable to current date
   22.81 -
   22.82 -        // convert 500SKK to CZK using c:
   22.83 -        // cannot convert as no rate is applicable to current date
   22.84 -
   22.85 -        // convert $5 to CZK using c at 2008-10-01 6:00 GMT:
   22.86 -        // assertEquals("Result is 85 CZK");
   22.87 -
   22.88 -        // convert $8 to CZK using c at 2008-10-01 6:00 GMT:
   22.89 -        // assertEquals("Result is 136 CZK");
   22.90 -
   22.91 -        // convert 1003CZK to USD using c at 2008-10-01 6:00 GMT:
   22.92 -        // assertEquals("Result is 59 USD");
   22.93 -
   22.94 -        // convert 16CZK using c at 2008-10-02 9:00 GMT:
   22.95 -        // assertEquals("Result is 20 SKK");
   22.96 -
   22.97 -        // convert 500SKK to CZK using c at 2008-10-02 9:00 GMT:
   22.98 -        // assertEquals("Result is 400 CZK");
   22.99 -
  22.100 -        // convert 500SKK to CZK using c at 2008-10-01 6:00 GMT:
  22.101 -        // cannot convert as no rate is applicable to current date
  22.102 -    }
  22.103 -
  22.104 -    /** Create convertor that understands two currencies, CZK and
  22.105 -     *  SKK. Make 100 SKK == 90 CZK.
  22.106 -     *
  22.107 -     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
  22.108 -     */
  22.109 -    public static Convertor createSKKtoCZK2() {
  22.110 -        return null;
  22.111 -    }
  22.112 -
  22.113 -    public void testDateConvetorWithTwoDifferentRates() throws Exception {
  22.114 -        if (Boolean.getBoolean("ignore.failing")) {
  22.115 -            // implement me! then delete this if statement
  22.116 -            return;
  22.117 -        }
  22.118 -
  22.119 -        Date d1 = null; // 2008-10-01 0:00 GMT
  22.120 -        Date d2 = null; // 2008-10-02 0:00 GMT
  22.121 -        Date d3 = null; // 2008-10-03 0:00 GMT
  22.122 -
  22.123 -        Convertor c = Task2Test.merge(
  22.124 -            limitTo(createSKKtoCZK2(), d1, d2),
  22.125 -            limitTo(Task1Test.createSKKtoCZK(), d2, d3)
  22.126 -        );
  22.127 -
  22.128 -        // convert 500SKK to CZK using c at 2008-10-02 9:00 GMT:
  22.129 -        // assertEquals("Result is 400 CZK");
  22.130 -
  22.131 -        // convert 500SKK to CZK using c at 2008-10-01 6:00 GMT:
  22.132 -        // assertEquals("Result is 450 CZK");
  22.133 -    }
  22.134 -
  22.135 -}