# HG changeset patch
# User japod@localhost
# Date 1223369931 -7200
# Node ID 2c8c32ad44f7179cb7646a1395f55c39f9a1043b
# Parent a7e6f84fb07831c7044774586fc342d32fcbb8e9
removing solutions with missing task2
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/build.xml
--- a/task2/solution01/build.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-
-
-
-
-
- Builds, tests, and runs the project.
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/nbproject/build-impl.xml
--- a/task2/solution01/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/nbproject/genfiles.properties
--- a/task2/solution01/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=2ab820eb
-build.xml.script.CRC32=58a52595
-build.xml.stylesheet.CRC32=be360661
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=3cae0313
-nbproject/build-impl.xml.script.CRC32=3c8caa17
-nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/nbproject/project.properties
--- a/task2/solution01/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-application.title=currency
-application.vendor=apidesign.org
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/currency.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
-file.reference.src-apifest08=..
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.source=1.5
-javac.target=1.5
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${file.reference.junit-4.4.jar}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-jnlp.codebase.type=local
-jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
-jnlp.descriptor=application
-jnlp.enabled=false
-jnlp.offline-allowed=false
-jnlp.signed=false
-meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-src.dir=src
-test.src.dir=test
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/nbproject/project.xml
--- a/task2/solution01/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Currency Convertor Solution 01
- 1.6.5
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/AbstractConvertorFactory.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/AbstractConvertorFactory.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * Abstract class for future possible purposes
- * @author Ladislav Vitasek
- */
-abstract class AbstractConvertorFactory implements CurrencyConvertorFactory{
-
- AbstractConvertorFactory() {
- }
-
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/AbstractCurrencyConvertor.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/AbstractCurrencyConvertor.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.Currency;
-
-/**
- * Abstract convertor implementation.
- * This class provide necessary stuff for creating any CurrencyConvertor
- * Convert value can be get by different way. Conversion should be made in its subclass.
- * @author Ladislav Vitasek
- */
-abstract class AbstractCurrencyConvertor implements Convertor {
- protected final ConversionRatioProvider conversionRatioProvider;
- protected final Currency currency1;
- protected final Currency currency2;
-
- public AbstractCurrencyConvertor(Currency currency1, Currency currency2, ConversionRatioProvider conversionRatioProvider) {
- this.currency1 = currency1;
- this.currency2 = currency2;
- this.conversionRatioProvider = conversionRatioProvider;
- }
-
-
- public Currency getCurrency1() {
- return currency1;
- }
-
-
- public Currency getCurrency2() {
- return currency2;
- }
-
-// /**
-// * Conversion value can be get by Different way. Let's decide subclass where to get actual value
-// * @return current value of conversion constant
-// */
-// protected abstract BigDecimal getConversionValue();
-
- @SuppressWarnings({"RedundantIfStatement"})
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- AbstractCurrencyConvertor that = (AbstractCurrencyConvertor) o;
-
- if (!conversionRatioProvider.equals(that.conversionRatioProvider)) return false;
- if (!currency1.equals(that.currency1)) return false;
- if (!currency2.equals(that.currency2)) return false;
-
- return true;
- }
-
- public int hashCode() {
- int result;
- result = conversionRatioProvider.hashCode();
- result = 31 * result + currency1.hashCode();
- result = 31 * result + currency2.hashCode();
- return result;
- }
-
- ConversionRatioProvider getConversionRatioProvider() {
- return conversionRatioProvider;
- }
-
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/CannotConvertException.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/CannotConvertException.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * If something was wrong during converting currencies...
- * Eg. when the convertor is outdated
- * Should be a descendant of RuntimeException? Hmmms...
- * @author Ladislav Vitasek
- */
-public class CannotConvertException extends RuntimeException {
-
- public CannotConvertException() {
-
- }
-
- public CannotConvertException(String message) {
- super(message);
- }
-
- public CannotConvertException(Throwable e) {
- super(e);
- }
-
- public CannotConvertException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/CannotInstantiateFactoryException.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/CannotInstantiateFactoryException.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * Failed to instantiate class for factory
- * @author Ladislav Vitasek
- */
-public class CannotInstantiateFactoryException extends Exception {
- public CannotInstantiateFactoryException(Throwable e) {
- super(e);
- }
-
- public CannotInstantiateFactoryException(String message) {
- super(message);
- }
-
- public CannotInstantiateFactoryException() {
- super();
- }
-
- public CannotInstantiateFactoryException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/CannotProvideValueException.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/CannotProvideValueException.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * Used when value cannot be get from the source
- * @author Ladislav Vitasek
- */
-public class CannotProvideValueException extends RuntimeException {
-
- public CannotProvideValueException() {
- super();
- }
-
- public CannotProvideValueException(String message) {
- super(message);
- }
-
- public CannotProvideValueException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public CannotProvideValueException(Throwable cause) {
- super(cause);
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/ConversionProperties.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/ConversionProperties.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
-/**
- * This class encapsulates settings for currency conversion
- * We can use it eg. for uptime options etc. in future versions
- *
- * @author Ladislav Vitasek
- */
-final public class ConversionProperties {
-
- private final ConversionRatioProvider conversionRatioProvider;
- private final RoundingMode roundingMode;
-
- /**
- * Returns conversion constants - conversion operation is invertable
- * Default
- */
- private final static class FixedBidirectionalRatioConversion implements ConversionRatioProvider {
- private final BigDecimal currency1ToCurrency2Constant;
- private final BigDecimal currency2ToCurrency1Constant;
- private static final int SCALE_MAX_DEFAULT = 20;
-
- /**
- * Constructor
- * @param ratioConstant fixed ratio constant
- * @param mode math rounding mode
- * @throws IllegalArgumentException if conversion value is <= 0
- */
- private FixedBidirectionalRatioConversion(BigDecimal ratioConstant, RoundingMode mode) {
- if (ratioConstant.compareTo(BigDecimal.ZERO) <= 0)
- throw new IllegalArgumentException("Conversion value cannot be <= 0");
- this.currency1ToCurrency2Constant = ratioConstant;
- this.currency2ToCurrency1Constant = BigDecimal.ONE.setScale(SCALE_MAX_DEFAULT).divide(ratioConstant, mode);
- }
-
- public BigDecimal getCurrency1ToCurrency2Constant() {
- return currency1ToCurrency2Constant;
- }
-
- public BigDecimal getCurrency2ToCurrency1Constant() {
- return currency2ToCurrency1Constant;
- }
- }
-
-
- /**
- * Returns new instance Conversion properties - fixed conversion ratio - both directions
- * Default max scale is set to 20
- *
- * @param conversionConstant value of constant for conversion
- * @param roundingMode math rounding mode
- * @return new instance of ConversionProperties class
- * @throws IllegalArgumentException if conversion constant is <= 0
- * @see org.apidesign.apifest08.currency.ConversionProperties.FixedBidirectionalRatioConversion
- */
- public static ConversionProperties create(BigDecimal conversionConstant, RoundingMode roundingMode) {
- return create(new FixedBidirectionalRatioConversion(conversionConstant, roundingMode), roundingMode);
- }
-
- /**
- * Returns new instance Conversion properties
- *
- * @param conversionRatioProvider provider for conversion constants
- * @param roundingMode math rounding mode
- * @return new instance of ConversionProperties class
- */
- public static ConversionProperties create(ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode) {
- if (conversionRatioProvider == null || roundingMode == null)
- throw new NullPointerException();
- return new ConversionProperties(conversionRatioProvider, roundingMode);
- }
-
- /**
- * Returns new instance Conversion properties with values set to conversionConstant=BigDecimal.ONE
- * and roundingMode=RoundingMode.HALF_EVEN
- *
- * Conversion is bidirectional.
- *
- * @return
- */
- public static ConversionProperties createDefault() {
- return create(BigDecimal.ONE, RoundingMode.HALF_EVEN);
- }
-
- private ConversionProperties(ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode) {
- this.conversionRatioProvider = conversionRatioProvider;
- this.roundingMode = roundingMode;
- }
-
-
- public RoundingMode getRoundingMode() {
- return roundingMode;
- }
-
- public ConversionRatioProvider getConversionRatioProvider() {
- return conversionRatioProvider;
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/ConversionRatioProvider.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/ConversionRatioProvider.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.math.BigDecimal;
-
-/**
- * Provider for conversion constant from any source
- * @author Ladislav Vitasek
- */
-public interface ConversionRatioProvider {
- public BigDecimal getCurrency1ToCurrency2Constant() throws CannotProvideValueException;
- public BigDecimal getCurrency2ToCurrency1Constant() throws CannotProvideValueException;
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/Convertor.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.math.BigDecimal;
-import java.util.Currency;
-
-/** This is the skeleton class for your API. You need to make it public, so
- * it is accessible to your client code (currently in Task1Test.java) file.
- *
- * Feel free to create additional classes or rename this one, just keep all
- * the API and its implementation in this package. Do not spread it outside
- * to other packages.
- */
-public interface Convertor {
- /**
- * Methods converts some pounds
- * API design question - what kind of parameters?
- * I decided to use BigDecimal based on experience on Java conf ;-)
- * @param amountOfMoney
- * @return converted amount of money
- * @throws org.apidesign.apifest08.currency.CannotConvertException - if convertor is outdated or any other problem
- */
-
- BigDecimal convertCurrency1ToCurrency2(BigDecimal amountOfMoney) throws CannotConvertException;
-
- /**
- * Methods converts some pounds
- * API design question - what kind of parameters?
- * @param amountOfMoney
- * @return converted amount of money
- * @throws org.apidesign.apifest08.currency.CannotConvertException - if convertor is outdated or any other problem
- */
-
- BigDecimal convertCurrency2ToCurrency1(BigDecimal amountOfMoney) throws CannotConvertException;
-
- //handy getters
-
- /**
- * Getter - Returns Currency 1 of this convertor
- * @return money code
- */
- Currency getCurrency1();
-
- /**
- * Getter - Returns Currency 2 of this convertor
- * @return money code
- */
- Currency getCurrency2();
-
- // For Future purposes...? - it was not as a requirement in TestCase
- //BigDecimal getConversionValue();
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/ConvertorNotAvailableException.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/ConvertorNotAvailableException.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * No convertor is available for current conversion settings
- * @author Ladislav Vitasek
- */
-public class ConvertorNotAvailableException extends Exception {
- public ConvertorNotAvailableException() {
-
- }
-
- public ConvertorNotAvailableException(String message) {
- super(message);
- }
-
- public ConvertorNotAvailableException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ConvertorNotAvailableException(Throwable cause) {
- super(cause);
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/ConvertorsFactory.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/ConvertorsFactory.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * Some Factory for Factories :-)
- * Depends on the whole application design...
- * @author Ladislav Vitasek
- */
-final public class ConvertorsFactory {
- private CurrencyConvertorFactory currencyConvertorFactoryInstance = null;
- private final static ConvertorsFactory instance = new ConvertorsFactory();
-
-
- private ConvertorsFactory() {
-
- }
-
- public static CurrencyConvertorFactory getCurrencyConvertorFactoryInstance() throws CannotInstantiateFactoryException {
- return getInstance().getCurrencyConvertor();
- }
-
- /**
- * Returns instance of CurrencyConvertorFactory
- * @return new instance of CurrencyConvertorFactory
- * @throws CannotInstantiateFactoryException
- */
- private synchronized CurrencyConvertorFactory getCurrencyConvertor() throws CannotInstantiateFactoryException {
- if (currencyConvertorFactoryInstance == null) {//intern implementation
-// String className = System.getProperty("currencyFactory", CurrencyConvertorFactoryImpl.class.getName());
-// try {
-// currencyConvertorFactoryInstance = (CurrencyConvertorFactory) Class.forName(className).newInstance();
-// } catch (Exception e) {
-// throw new CannotInstantiateFactoryException(e);
-// }
- //without reflection
- currencyConvertorFactoryInstance = new CurrencyConvertorFactoryImpl();
- }
- return currencyConvertorFactoryInstance;
- }
-
- public static ConvertorsFactory getInstance() {
- return instance;
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactory.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactory.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.Currency;
-
-/**
- * @author Ladislav Vitasek
- */
-public interface CurrencyConvertorFactory {
-
- /**
- * Instantiate a new instance convertor
- * @param currency1 a code currency you want to convert between
- * @param currency2 a code currency you want to convert between
- * @param conversionProperties settings for conversion
- * @return converter for currency converting
- * @throws ConvertorNotAvailableException throws if there is no available convertor for selected currencies
- */
- Convertor createConvertor(Currency currency1, Currency currency2, ConversionProperties conversionProperties) throws ConvertorNotAvailableException;
-
-
-
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactoryImpl.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorFactoryImpl.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.Currency;
-
-/**
- * Convertor Factory implementation
- * In the real-time world this code should be optimized - convertors caching etc.
- * @author Ladislav Vitasek
- */
-class CurrencyConvertorFactoryImpl extends AbstractConvertorFactory {
-
-
- CurrencyConvertorFactoryImpl() {
- super();
- }
-
- // Note - implementation of this method is dummy
-
- public Convertor createConvertor(Currency currency1, Currency currency2, ConversionProperties conversionProperties) throws ConvertorNotAvailableException {
- if (currency1 == null || currency2 == null || conversionProperties == null)
- throw new NullPointerException();
-
- try {
- return new CurrencyConvertorImpl(currency1, currency2, conversionProperties.getConversionRatioProvider(), conversionProperties.getRoundingMode());//can be cached somehow
- } catch (Exception e) {
- throw new ConvertorNotAvailableException(e);
- }
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorImpl.java
--- a/task2/solution01/src/org/apidesign/apifest08/currency/CurrencyConvertorImpl.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.Currency;
-
-/**
- * Intern implementation of Bidirectional Convertor - this class is only for internal purposes only.
- * This implementation uses BigDecimals to count result value
- * Scale is set by ISO 4217 as default
- *
- * @author Ladislav Vitasek
- */
-class CurrencyConvertorImpl extends AbstractCurrencyConvertor {
-
- protected RoundingMode roundingMode;
- protected int currency1Scale;
- protected int currency2Scale;
-
- /**
- * Constructor
- * By default it creates convertor with conversion value 1
- *
- * @param currency1 currency for conversion
- * @param currency2 currency for conversion
- * @param provider constants provider
- * @param roundingMode math rounding mode
- */
- CurrencyConvertorImpl(Currency currency1, Currency currency2, ConversionRatioProvider provider, RoundingMode roundingMode) {
- this(currency1, currency2, provider, roundingMode, currency1.getDefaultFractionDigits(), currency2.getDefaultFractionDigits());
- }
-
- /**
- * Constructor
- *
- * @param currency1 currency for conversion
- * @param currency2 currency for conversion
- * @param conversionRatioProvider conversion constants provider
- * @param roundingMode math rounding mode
- * @param conversionRatioProvider constants provider
- * @param currency2Scale
- */
- CurrencyConvertorImpl(Currency currency1, Currency currency2, ConversionRatioProvider conversionRatioProvider, RoundingMode roundingMode, int currency1Scale, int currency2Scale) {
- super(currency1, currency2, conversionRatioProvider);
- this.roundingMode = roundingMode;
- this.currency1Scale = currency1Scale;
- this.currency2Scale = currency2Scale;
- }
-
-
- public BigDecimal convertCurrency1ToCurrency2(BigDecimal amountOfMoney) throws CannotConvertException {
- try {
- final BigDecimal result = amountOfMoney.multiply(getConversionRatioProvider().getCurrency1ToCurrency2Constant());
- return result.setScale(getCurrency2Scale(), getRoundingMode());
- } catch (CannotProvideValueException e) {
- throw new CannotConvertException(e);
- } catch (ArithmeticException e) {
- throw new CannotConvertException(e);
- }
- }
-
-
- public BigDecimal convertCurrency2ToCurrency1(BigDecimal amountOfMoney) throws CannotConvertException {
- try {
- final BigDecimal result = amountOfMoney.multiply(getConversionRatioProvider().getCurrency2ToCurrency1Constant());
- return result.setScale(getCurrency1Scale(), getRoundingMode());
- } catch (CannotProvideValueException e) {
- throw new CannotConvertException(e);
- } catch (ArithmeticException e) {
- throw new CannotConvertException(e);
- }
- }
-
- public String toString() {
- return "CurrencyConvertorImpl{" +
- "currency1=" + getCurrency1() +
- ",currency2=" + getCurrency2() +
- ", roundingMode=" + roundingMode +
- ", currency1Scale=" + currency1Scale +
- ", currency2Scale=" + currency2Scale +
- '}';
- }
-
- RoundingMode getRoundingMode() {
- return roundingMode;
- }
-
- int getCurrency1Scale() {
- return currency1Scale;
- }
-
- int getCurrency2Scale() {
- return currency2Scale;
- }
-
- void setRoundingMode(RoundingMode roundingMode) {
- this.roundingMode = roundingMode;
- }
-
- void setCurrency1Scale(int currency1Scale) {
- this.currency1Scale = currency1Scale;
- }
-
- void setCurrency2Scale(int currency2Scale) {
- this.currency2Scale = currency2Scale;
- }
-
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution01/test/org/apidesign/apifest08/test/Task1Test.java
--- a/task2/solution01/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-package org.apidesign.apifest08.test;
-
-import junit.framework.TestCase;
-import org.apidesign.apifest08.currency.*;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.Currency;
-
-/**
- * Finish the Convertor API, and then write bodies of methods inside
- * of this class to match the given tasks. To fullfil your task, use the
- * API define in the org.apidesign.apifest08.currency
package.
- * Do not you reflection, or other hacks as your code
- * shall run without any runtime permissions.
- */
-public class Task1Test extends TestCase {
- private static CurrencyConvertorFactory currencyConvertorFactoryInstance;
-
- public Task1Test(String testName) {
- super(testName);
- }
-
- @Override
- protected void setUp() throws Exception {
- currencyConvertorFactoryInstance = ConvertorsFactory.getCurrencyConvertorFactoryInstance();
- }
-
- @Override
- protected void tearDown() throws Exception {
- currencyConvertorFactoryInstance = null;
- }
-
- /**
- * Create convertor that understands two currencies, CZK and
- * USD. Make 1 USD == 17 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting USD to CZK and CZK to USD
- */
- public static Convertor createCZKtoUSD() throws ConvertorNotAvailableException {
- final Currency czk = Currency.getInstance("CZK");
- final Currency usd = Currency.getInstance("USD");
- final BigDecimal constant = BigDecimal.ONE.divide(BigDecimal.valueOf(17), 10, RoundingMode.HALF_EVEN);
- return currencyConvertorFactoryInstance.createConvertor(czk, usd, ConversionProperties.create(constant, RoundingMode.HALF_EVEN));
- }
-
- /**
- * Create convertor that understands two currencies, CZK and
- * SKK. Make 100 SKK == 80 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
- */
- public static Convertor createSKKtoCZK() throws ConvertorNotAvailableException {
- final Currency skk = Currency.getInstance("SKK");
- final Currency czk = Currency.getInstance("CZK");
- final BigDecimal constant = new BigDecimal("0.8");
- return currencyConvertorFactoryInstance.createConvertor(skk, czk, ConversionProperties.create(constant, RoundingMode.HALF_EVEN));
- }
-
- /**
- * Use the convertor from createCZKtoUSD
method and do few conversions
- * with it.
- */
- public void testCurrencyCZKUSD() throws Exception {
- Convertor c = createCZKtoUSD();
- // convert $5 to CZK using c:
-
- final int czkDigitsScale = c.getCurrency1().getDefaultFractionDigits();
- final int usdDigitsScale = c.getCurrency2().getDefaultFractionDigits();
-
- assertEquals("Result is 85 CZK", BigDecimal.valueOf(85).setScale(czkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(5)));
-
- // convert $8 to CZK
- assertEquals("Result is 136 CZK", BigDecimal.valueOf(136).setScale(czkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(8)));
-
- // convert 1003CZK to USD
- assertEquals("Result is 59 USD", BigDecimal.valueOf(59).setScale(usdDigitsScale), c.convertCurrency1ToCurrency2(BigDecimal.valueOf(1003)));
- }
-
- /**
- * Use the convertor from createSKKtoCZK
method and do few conversions
- * with it.
- */
- public void testCurrencySKKCZK() throws Exception {
- Convertor c = createSKKtoCZK();
- // convert 16CZK using c:
-
- final int skkDigitsScale = c.getCurrency1().getDefaultFractionDigits();
- final int czkDigitsScale = c.getCurrency2().getDefaultFractionDigits();
-
- assertEquals("Result is 20 SKK", BigDecimal.valueOf(20).setScale(skkDigitsScale), c.convertCurrency2ToCurrency1(BigDecimal.valueOf(16)));
-
- // convert 500SKK to CZK
- assertEquals("Result is 400 CZK", BigDecimal.valueOf(400).setScale(czkDigitsScale), c.convertCurrency1ToCurrency2(BigDecimal.valueOf(500)));
- }
-
-}
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution03/build.xml
--- a/task2/solution03/build.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-
-
-
-
-
- Builds, tests, and runs the project.
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution03/nbproject/build-impl.xml
--- a/task2/solution03/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution03/nbproject/genfiles.properties
--- a/task2/solution03/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=2ab820eb
-build.xml.script.CRC32=58a52595
-build.xml.stylesheet.CRC32=be360661
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=ec91bd4b
-nbproject/build-impl.xml.script.CRC32=593428f7
-nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution03/nbproject/project.properties
--- a/task2/solution03/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-application.title=currency
-application.vendor=apidesign.org
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/currency.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
-file.reference.src-apifest08=..
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.source=1.5
-javac.target=1.5
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${file.reference.junit-4.4.jar}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-jnlp.codebase.type=local
-jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
-jnlp.descriptor=application
-jnlp.enabled=false
-jnlp.offline-allowed=false
-jnlp.signed=false
-meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-src.dir=src
-test.src.dir=test
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution03/nbproject/project.xml
--- a/task2/solution03/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Currency Convertor Solution 03
- 1.6.5
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution03/src/org/apidesign/apifest08/currency/Convertor.java
--- a/task2/solution03/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/** This is the skeleton class for your API. You need to make it public, so
- * it is accessible to your client code (currently in Task1Test.java) file.
- *
- * Feel free to create additional classes or rename this one, just keep all
- * the API and its implementation in this package. Do not spread it outside
- * to other packages.
- */
-public class Convertor {
-
- public static final int FIRST_TO_SECOND = 1;
-
- public static final int SECOND_TO_FIRST = 2;
-
- private double first;
-
- private double second;
-
- public Convertor(double first, double second) {
- this.first = first;
- this.second = second;
- }
-
- public double convertFirstToSecond(double value) {
- return (second / first) * value;
- }
-
- public double convertSecondToFirst(double value) {
- return (first / second) * value;
- }
-
- public double convert(double value, int typeOfConvert) {
- if (FIRST_TO_SECOND == typeOfConvert) {
- return convertFirstToSecond(value);
- } else if (SECOND_TO_FIRST == typeOfConvert) {
- return convertSecondToFirst(value);
- }
- throw new IllegalArgumentException("Unkown type of convert.");
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution03/test/org/apidesign/apifest08/test/Task1Test.java
--- a/task2/solution03/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-package org.apidesign.apifest08.test;
-
-import junit.framework.TestCase;
-import org.apidesign.apifest08.currency.Convertor;
-
-/** Finish the Convertor API, and then write bodies of methods inside
- * of this class to match the given tasks. To fullfil your task, use the
- * API define in the org.apidesign.apifest08.currency
package.
- * Do not you reflection, or other hacks as your code
- * shall run without any runtime permissions.
- */
-public class Task1Test extends TestCase {
-
- public Task1Test(String testName) {
- super(testName);
- }
-
- @Override
- protected void setUp() throws Exception {
- }
-
- @Override
- protected void tearDown() throws Exception {
- }
-
- /** Create convertor that understands two currencies, CZK and
- * USD. Make 1 USD == 17 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting USD to CZK and CZK to USD
- */
- public static Convertor createCZKtoUSD() {
- return new Convertor(17, 1);
- }
-
- /** Create convertor that understands two currencies, CZK and
- * SKK. Make 100 SKK == 80 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
- */
- public static Convertor createSKKtoCZK() {
- return new Convertor(100, 80);
- }
-
- /** Use the convertor from createCZKtoUSD
method and do few conversions
- * with it.
- */
- public void testCurrencyCZKUSD() throws Exception {
- Convertor c = createCZKtoUSD();
- // convert $5 to CZK using c:
- // assertEquals("Result is 85 CZK");
- assertEquals(c.convert(5, Convertor.SECOND_TO_FIRST), (double) 85);
-
- // convert $8 to CZK
- // assertEquals("Result is 136 CZK");
- assertEquals(c.convert(8, Convertor.SECOND_TO_FIRST), (double) 136);
-
- // convert 1003CZK to USD
- // assertEquals("Result is 59 USD");
- assertEquals(c.convert(1003, Convertor.FIRST_TO_SECOND), (double) 59);
- }
-
- /** Use the convertor from createSKKtoCZK
method and do few conversions
- * with it.
- */
- public void testCurrencySKKCZK() throws Exception {
- Convertor c = createSKKtoCZK();
- // convert 16CZK using c:
- // assertEquals("Result is 20 SKK");
- assertEquals(c.convert(16, Convertor.SECOND_TO_FIRST), (double) 20);
-
- // convert 500SKK to CZK
- // assertEquals("Result is 400 CZK");
- assertEquals(c.convert(500, Convertor.FIRST_TO_SECOND), (double) 400);
- }
-}
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/build.xml
--- a/task2/solution05/build.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-
-
-
-
-
- Builds, tests, and runs the project.
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/nbproject/build-impl.xml
--- a/task2/solution05/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/nbproject/genfiles.properties
--- a/task2/solution05/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=2ab820eb
-build.xml.script.CRC32=58a52595
-build.xml.stylesheet.CRC32=be360661
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=47a079e2
-nbproject/build-impl.xml.script.CRC32=f7fdafd7
-nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/nbproject/project.properties
--- a/task2/solution05/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-application.title=currency
-application.vendor=apidesign.org
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/currency.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
-file.reference.src-apifest08=..
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.source=1.5
-javac.target=1.5
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${file.reference.junit-4.4.jar}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-jnlp.codebase.type=local
-jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
-jnlp.descriptor=application
-jnlp.enabled=false
-jnlp.offline-allowed=false
-jnlp.signed=false
-meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-src.dir=src
-test.src.dir=test
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/nbproject/project.xml
--- a/task2/solution05/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Currency Convertor Solution 05
- 1.6.5
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/src/org/apidesign/apifest08/currency/Amount.java
--- a/task2/solution05/src/org/apidesign/apifest08/currency/Amount.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * Amount is a class reprezenting an amount of many. It consist of
- * whole currency amount and of pence amount. Both items are long values
- * and it's not defined that the 100 pences = 1 amount. It's up to the converter
- * to verify such invariants.
- *
- * @author jindra
- */
-public final class Amount {
-
- private long amount;
- private long pence;
-
- /**
- * Construct Amount with no pences.
- *
- * @param amount the amount in some currency
- *
- */
- public Amount(long amount) {
- this.amount = amount;
- this.pence = 0;
- }
-
- /**
- * Construct Amount with the pences.
- *
- * @param amount the amount in some currency
- * @param pence the pence count
- */
- public Amount(long amount, long pence) {
- this.amount = amount;
- this.pence = pence;
- }
-
- /**
- * @return the amount
- */
- public long getAmount() {
- return amount;
- }
-
- /**
- * @param amount the amount to set
- */
- public void setAmount(long amount) {
- this.amount = amount;
- }
-
- /**
- * @return the pence
- */
- public long getPence() {
- return pence;
- }
-
- /**
- * @param pence the pence to set
- */
- public void setPence(long pence) {
- this.pence = pence;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof Amount)) {
- return false;
- }
- Amount other = (Amount) obj;
- return (amount == other.amount) && (pence == other.pence);
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 79 * hash + (int) (this.amount ^ (this.amount >>> 32));
- hash = 79 * hash + (int) (this.pence ^ (this.pence >>> 32));
- return hash;
- }
-
- @Override
- public String toString() {
- return amount + "." + pence;
- }
-
-
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/src/org/apidesign/apifest08/currency/Convertor.java
--- a/task2/solution05/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * Convertor is an interface reprezenting a convertor between currencies.
- * It's able to convert one currency to the second one and back from the second one
- * to the primary.
- */
-public interface Convertor {
-
- /**
- * Convert amount of primary currency into secondary currency
- *
- * @param amount the amount in the primary currency
- * @return an amount in the secondary currency
- */
- Amount convert(Amount primaryAmount);
-
- /**
- * Convert amount of secondary currency back into primary currency
- *
- * @param amount the amount in the secondary currency
- * @return an amount in the primary currency
- */
- Amount convertBack(Amount secondaryAmount);
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java
--- a/task2/solution05/src/org/apidesign/apifest08/currency/ConvertorFactory.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * Convertor factory is a factory class for creating {@link Convertor Convertor}
- * instances.
- *
- * @author jindra
- */
-public final class ConvertorFactory {
-
- // this class needs no instances
- private ConvertorFactory() {
- }
-
-
- /**
- * Create a {@link Convertor Convertor} with given exchange rate
- *
- * @param exchangeRate double reprezenting the exchange rate from primary currency into
- * the secundary currecny
- * @return {@link Convertor Convertor} instance with given exchange rate
- */
- public static Convertor createConvertor(double exchangeRate) {
- if (exchangeRate == 0) {
- throw new IllegalArgumentException("Zero exchange rate is not allowed.");
- }
- return new ConvertorImpl(exchangeRate);
-
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/src/org/apidesign/apifest08/currency/ConvertorImpl.java
--- a/task2/solution05/src/org/apidesign/apifest08/currency/ConvertorImpl.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/**
- * ConvetorImpl it the basic implementaion of Convertor interface.
- * @see Convertor Convertor for more details.
- * The 100 pences makes 1 amount of the currency.
- *
- * @author jindra
- */
-final class ConvertorImpl implements Convertor {
-
- private static final double P_TO_AM = 100;
- private double exchangeRate;
-
- ConvertorImpl(double exchangeRate) {
- this.exchangeRate = exchangeRate;
- }
-
- public Amount convert(Amount amount) {
- verifyInput(amount);
- double result = convertToDouble(amount) * exchangeRate;
- return convertToAmount(result);
- }
-
- public Amount convertBack(Amount amount) {
- if (amount == null) {
- throw new IllegalArgumentException("Amount must be not null");
- }
- double result = convertToDouble(amount) / exchangeRate;
- return convertToAmount(result);
- }
-
- private double convertToDouble(Amount amount) {
- double am = amount.getAmount();
- double pc = amount.getPence();
- return am + (pc / P_TO_AM);
- }
-
- private Amount convertToAmount(double result) {
- long resultAm = Math.round(Math.floor(result));
- long resultPc = Math.round(Math.floor((result * P_TO_AM - resultAm * P_TO_AM)));
- return new Amount(resultAm, resultPc);
- }
-
- private void verifyInput(Amount amount) {
- if (amount == null) {
- throw new IllegalArgumentException("Amount must be not null");
- }
- if (amount.getPence() < 0) {
- throw new IllegalArgumentException("Pences must not be negative");
- }
- if (amount.getPence() > P_TO_AM) {
- throw new IllegalArgumentException("Pences must not be over P_TO_AM");
- }
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution05/test/org/apidesign/apifest08/test/Task1Test.java
--- a/task2/solution05/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-package org.apidesign.apifest08.test;
-
-import junit.framework.TestCase;
-import org.apidesign.apifest08.currency.Amount;
-import org.apidesign.apifest08.currency.Convertor;
-import org.apidesign.apifest08.currency.ConvertorFactory;
-
-/** Finish the Convertor API, and then write bodies of methods inside
- * of this class to match the given tasks. To fullfil your task, use the
- * API define in the org.apidesign.apifest08.currency
package.
- * Do not you reflection, or other hacks as your code
- * shall run without any runtime permissions.
- */
-public class Task1Test extends TestCase {
- public Task1Test(String testName) {
- super(testName);
- }
-
- @Override
- protected void setUp() throws Exception {
- }
-
- @Override
- protected void tearDown() throws Exception {
- }
-
- /** Create convertor that understands two currencies, CZK and
- * USD. Make 1 USD == 17 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting USD to CZK and CZK to USD
- */
- public static Convertor createCZKtoUSD() {
- return ConvertorFactory.createConvertor(17);
- }
-
- /** Create convertor that understands two currencies, CZK and
- * SKK. Make 100 SKK == 80 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
- */
- public static Convertor createSKKtoCZK() {
- return ConvertorFactory.createConvertor(0.8);
- }
-
- /** Use the convertor from createCZKtoUSD
method and do few conversions
- * with it.
- */
- public void testCurrencyCZKUSD() throws Exception {
- Convertor c = createCZKtoUSD();
- // convert $5 to CZK using c:
- assertEquals("Result is 85 CZK", 85l, c.convert(new Amount(5)).getAmount());
-
- // convert $8 to CZK
- assertEquals("Result is 136 CZK", 136l, c.convert(new Amount(8)).getAmount());
-
- // convert 1003CZK to USD
- assertEquals("Result is 136 CZK", 59l, c.convertBack(new Amount(1003)).getAmount());
- // assertEquals("Result is 59 USD");
- }
-
- /** Use the convertor from createSKKtoCZK
method and do few conversions
- * with it.
- */
- public void testCurrencySKKCZK() throws Exception {
- Convertor c = createSKKtoCZK();
- // convert 16CZK using c:
- assertEquals("Result is 20 SKK", 20l, c.convertBack(new Amount(16)).getAmount());
-
- // convert 500SKK to CZK
- assertEquals("Result is 400 CZK", 400l, c.convert(new Amount(500)).getAmount());
- }
-
- /** Use the convertor from createSKKtoCZK
method and do few conversions
- * with it.
- */
- public void testCurrencySKKCZKwithPences() throws Exception {
- Convertor c = createSKKtoCZK();
- // convert 16CZK 16h using c:
- assertEquals("Result is 20 SKK 20h", new Amount(20, 20), c.convertBack(new Amount(16, 16)));
-
- // convert 500SKK 80h to CZK
- assertEquals("Result is 400 CZK 64h", new Amount(400, 64), c.convert(new Amount(500, 80)));
-
- // convert 400CZK 80h to SKK
- assertEquals("Result is 501 CZK", new Amount(501), c.convertBack(new Amount(400, 80)));
- }
-
- public void testNegativeSKKCZ() throws Exception{
- Convertor c = createSKKtoCZK();
- // convert -16CZK using c:
- assertEquals("Result is -20", new Amount(-20), c.convertBack(new Amount(-16)));
-
- // convert -500SKK 80h to CZK
- assertEquals("Result is -400CZK 64h", new Amount(-400, 64), c.convert(new Amount(-500, 80)));
-
- }
-}
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution08/build.xml
--- a/task2/solution08/build.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-
-
-
-
-
- Builds, tests, and runs the project.
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution08/nbproject/build-impl.xml
--- a/task2/solution08/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution08/nbproject/genfiles.properties
--- a/task2/solution08/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=2ab820eb
-build.xml.script.CRC32=58a52595
-build.xml.stylesheet.CRC32=be360661
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=a2ad29dd
-nbproject/build-impl.xml.script.CRC32=43c3e6a6
-nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution08/nbproject/project.properties
--- a/task2/solution08/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-application.title=currency
-application.vendor=apidesign.org
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/currency.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
-file.reference.src-apifest08=..
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.source=1.5
-javac.target=1.5
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${file.reference.junit-4.4.jar}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-jnlp.codebase.type=local
-jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
-jnlp.descriptor=application
-jnlp.enabled=false
-jnlp.offline-allowed=false
-jnlp.signed=false
-meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-src.dir=src
-test.src.dir=test
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution08/nbproject/project.xml
--- a/task2/solution08/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Currency Convertor Solution 08
- 1.6.5
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution08/src/org/apidesign/apifest08/currency/Convertor.java
--- a/task2/solution08/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.Currency;
-import java.util.Hashtable;
-import java.util.Map;
-
-/** This is the skeleton class for your API. You need to make it public, so
- * it is accessible to your client code (currently in Task1Test.java) file.
- *
- * Feel free to create additional classes or rename this one, just keep all
- * the API and its implementation in this package. Do not spread it outside
- * to other packages.
- */
-public class Convertor {
-
- private static final Map EXCHANGE_RATES = new Hashtable() { {
- put("CZKUSD", 1/17F);
- put("USDCZK", 17F);
- put("SKKCZK", 100/80F);
- put("CZKSKK", 80/100F);
- }
- };
-
- private Currency currencyFirst;
- private Currency currencySecond;
-
- private Convertor(Currency currencyFirst, Currency currencySecond) {
- this.currencyFirst = currencyFirst;
- this.currencySecond = currencySecond;
- }
-
- public static Convertor getInstanceFor(Currency currencyFirst, Currency currencySecond) {
- return new Convertor(currencyFirst, currencySecond);
- }
-
- public float convert(float value, Currency toCurrency) {
- if (!toCurrency.equals(currencyFirst) && !toCurrency.equals(currencySecond)) {
- throw new IllegalArgumentException("Unsupported currency for this convertor!: " + toCurrency.getCurrencyCode());
- }
-
- Float rate = null;
- if (toCurrency.equals(currencyFirst)) {
- rate = EXCHANGE_RATES.get(currencyFirst.getCurrencyCode() + currencySecond.getCurrencyCode());
- }
- if (toCurrency.equals(currencySecond)) {
- rate = EXCHANGE_RATES.get(currencySecond.getCurrencyCode() + currencyFirst.getCurrencyCode());
- }
-
- if (rate == null) {
- throw new IllegalStateException("Undefinied conversion!");
- }
-
- return rate*value;
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution08/test/org/apidesign/apifest08/test/Task1Test.java
--- a/task2/solution08/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-package org.apidesign.apifest08.test;
-
-import java.util.Currency;
-import junit.framework.TestCase;
-import org.apidesign.apifest08.currency.Convertor;
-
-/** Finish the Convertor API, and then write bodies of methods inside
- * of this class to match the given tasks. To fullfil your task, use the
- * API define in the org.apidesign.apifest08.currency
package.
- * Do not you reflection, or other hacks as your code
- * shall run without any runtime permissions.
- */
-public class Task1Test extends TestCase {
- public Task1Test(String testName) {
- super(testName);
- }
-
- @Override
- protected void setUp() throws Exception {
- }
-
- @Override
- protected void tearDown() throws Exception {
- }
-
- /** Create convertor that understands two currencies, CZK and
- * USD. Make 1 USD == 17 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting USD to CZK and CZK to USD
- */
- public static Convertor createCZKtoUSD() {
- return Convertor.getInstanceFor(Currency.getInstance("CZK"), Currency.getInstance("USD"));
- }
-
- /** Create convertor that understands two currencies, CZK and
- * SKK. Make 100 SKK == 80 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
- */
- public static Convertor createSKKtoCZK() {
- return Convertor.getInstanceFor(Currency.getInstance("SKK"), Currency.getInstance("CZK"));
- }
-
- /** Use the convertor from createCZKtoUSD
method and do few conversions
- * with it.
- */
- public void testCurrencyCZKUSD() throws Exception {
- Convertor c = createCZKtoUSD();
- Currency usd = Currency.getInstance("USD");
- Currency czk = Currency.getInstance("CZK");
- // convert $5 to CZK using c:
- // assertEquals("Result is 85 CZK");
- assertEquals(85F, c.convert(5, usd));
-
- // convert $8 to CZK
- // assertEquals("Result is 136 CZK");
- assertEquals(136F, c.convert(8, usd));
-
- // convert 1003CZK to USD
- // assertEquals("Result is 59 USD");
- assertEquals(59F, c.convert(1003, czk));
- }
-
- /** Use the convertor from createSKKtoCZK
method and do few conversions
- * with it.
- */
- public void testCurrencySKKCZK() throws Exception {
- Convertor c = createSKKtoCZK();
- Currency skk = Currency.getInstance("SKK");
- Currency czk = Currency.getInstance("CZK");
- // convert 16CZK using c:
- // assertEquals("Result is 20 SKK");
- assertEquals(20F, c.convert(16, skk));
-
- // convert 500SKK to CZK
- // assertEquals("Result is 400 CZK");
- assertEquals(400F, c.convert(500, czk));
- }
-}
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/build.xml
--- a/task2/solution09/build.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-
-
-
-
-
- Builds, tests, and runs the project.
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/nbproject/build-impl.xml
--- a/task2/solution09/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/nbproject/genfiles.properties
--- a/task2/solution09/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=2ab820eb
-build.xml.script.CRC32=58a52595
-build.xml.stylesheet.CRC32=be360661
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=cab2f6f1
-nbproject/build-impl.xml.script.CRC32=711fa7d6
-nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/nbproject/project.properties
--- a/task2/solution09/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-application.title=currency
-application.vendor=apidesign.org
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=8
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
-auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=default
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/currency.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
-file.reference.src-apifest08=..
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.source=1.5
-javac.target=1.5
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${file.reference.junit-4.4.jar}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-jnlp.codebase.type=local
-jnlp.codebase.url=file:/home/jarda/src/apifest08/currency/dist
-jnlp.descriptor=application
-jnlp.enabled=false
-jnlp.offline-allowed=false
-jnlp.signed=false
-meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-src.dir=src
-test.src.dir=test
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/nbproject/project.xml
--- a/task2/solution09/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Currency Convertor Solution 09
- 1.6.5
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/src/org/apidesign/apifest08/currency/Convertor.java
--- a/task2/solution09/src/org/apidesign/apifest08/currency/Convertor.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-/** This is the skeleton class for your API. You need to make it public, so
- * it is accessible to your client code (currently in Task1Test.java) file.
- *
- * Feel free to create additional classes or rename this one, just keep all
- * the API and its implementation in this package. Do not spread it outside
- * to other packages.
- */
-public interface Convertor {
-
- /**
- * converts amount in first currency to amount second currency.
- * @param amountInCents the amount of first currency in cents (or equivalent)
- * @return the amount in the second currency in cents (or equivalent)
- */
- public long convertTo(long amountInCents);
-
-
- /**
- * converts from second currency amount to first currency amount.
- * @param amountInCents the amount of second currency in cents (or equivalent)
- * @return the amount in the first currency in cents (or equivalent)
- */
- public long convertFrom(long amountInCents);
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/src/org/apidesign/apifest08/currency/ConvertorFactory.java
--- a/task2/solution09/src/org/apidesign/apifest08/currency/ConvertorFactory.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.math.BigDecimal;
-
-
-public class ConvertorFactory {
-
- public static Convertor getConvertor(CurrencyType from, CurrencyType to) {
- if (from == CurrencyType.CZK && to == CurrencyType.USD) {
- return new BasicConvertor(new BigDecimal(17));
- } else if (from == CurrencyType.SKK && to == CurrencyType.CZK) {
- double rate = 0.8d;
- return new BasicConvertor(new BigDecimal(rate));
- }
-
-
- throw new UnsupportedOperationException("Conversion not supported now");
- }
-
- private static class BasicConvertor implements Convertor {
-
- private final BigDecimal conversionRate;
-
- BasicConvertor(BigDecimal conversionRate) {
- this.conversionRate = conversionRate;
- }
-
- @Override
- public long convertTo(long amount) {
- return (long) (conversionRate.doubleValue() * amount);
- }
-
- @Override
- public long convertFrom(long amount) {
- return (long) (amount / conversionRate.doubleValue());
- }
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/src/org/apidesign/apifest08/currency/CurrencyType.java
--- a/task2/solution09/src/org/apidesign/apifest08/currency/CurrencyType.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-public enum CurrencyType {
-
- CZK, SKK, USD;
-
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution09/test/org/apidesign/apifest08/test/Task1Test.java
--- a/task2/solution09/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-package org.apidesign.apifest08.test;
-
-import junit.framework.TestCase;
-import org.apidesign.apifest08.currency.Convertor;
-import org.apidesign.apifest08.currency.ConvertorFactory;
-import org.apidesign.apifest08.currency.CurrencyType;
-
-/** Finish the Convertor API, and then write bodies of methods inside
- * of this class to match the given tasks. To fullfil your task, use the
- * API define in the org.apidesign.apifest08.currency
package.
- * Do not you reflection, or other hacks as your code
- * shall run without any runtime permissions.
- */
-public class Task1Test extends TestCase {
- public Task1Test(String testName) {
- super(testName);
- }
-
-
- /** Create convertor that understands two currencies, CZK and
- * USD. Make 1 USD == 17 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting USD to CZK and CZK to USD
- */
- public static Convertor createCZKtoUSD() {
- return ConvertorFactory.getConvertor(CurrencyType.CZK, CurrencyType.USD);
- }
-
- /** Create convertor that understands two currencies, CZK and
- * SKK. Make 100 SKK == 80 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
- */
- public static Convertor createSKKtoCZK() {
- return ConvertorFactory.getConvertor(CurrencyType.SKK, CurrencyType.CZK);
- }
-
- /** Use the convertor from createCZKtoUSD
method and do few conversions
- * with it.
- */
- public void testCurrencyCZKUSD() throws Exception {
- Convertor c = createCZKtoUSD();
-
- // convert $5 to CZK using c:
- // assertEquals("Result is 85 CZK");
- assertEquals(85, c.convertTo(5));
-
- // convert $8 to CZK
- // assertEquals("Result is 136 CZK");
- assertEquals(136, c.convertTo(8));
-
- // convert 1003CZK to USD
- // assertEquals("Result is 59 USD");
- assertEquals(59, c.convertFrom(1003));
- }
-
- /** Use the convertor from createSKKtoCZK
method and do few conversions
- * with it.
- */
- public void testCurrencySKKCZK() throws Exception {
- Convertor c = createSKKtoCZK();
- // convert 16CZK using c:
- // assertEquals("Result is 20 SKK");
- assertEquals(20, c.convertFrom(16));
-
- // convert 500SKK to CZK
- // assertEquals("Result is 400 CZK");
- assertEquals(400, c.convertTo(500));
- }
-}
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/build.xml
--- a/task2/solution10/build.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-
-
-
-
-
- Builds, tests, and runs the project Currency Convertor Solution 10.
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/nbproject/.DS_Store
Binary file task2/solution10/nbproject/.DS_Store has changed
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/nbproject/build-impl.xml
--- a/task2/solution10/nbproject/build-impl.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
-
-
-
-
-
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/nbproject/genfiles.properties
--- a/task2/solution10/nbproject/genfiles.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=6601af03
-build.xml.script.CRC32=2c84d7b2
-build.xml.stylesheet.CRC32=be360661
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=6601af03
-nbproject/build-impl.xml.script.CRC32=5e67461a
-nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/nbproject/project.properties
--- a/task2/solution10/nbproject/project.properties Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-application.title=basic
-application.vendor=vvessan
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/Currency_Convertor_Solution_10.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-excludes=
-file.reference.junit-4.4.jar=../../libs/junit-4.4.jar
-includes=**
-jar.compress=false
-javac.classpath=
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.source=1.5
-javac.target=1.5
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${file.reference.junit-4.4.jar}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/nbproject/project.xml
--- a/task2/solution10/nbproject/project.xml Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-
- org.netbeans.modules.java.j2seproject
-
-
- Currency Convertor Solution 10
- 1.6.5
-
-
-
-
-
-
-
-
-
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/src/org/apidesign/apifest08/currency/ConstantRateConverter.java
--- a/task2/solution10/src/org/apidesign/apifest08/currency/ConstantRateConverter.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.*;
-
-final class ConstantRateConverter implements CurrencyConverter {
-
- private final Currency from;
- private final Currency to;
-
- private final double rate;
-
- public ConstantRateConverter(Currency from, Currency to, double rate) throws IllegalArgumentException {
- if (from == null || to == null)
- throw new NullPointerException("None of the currencies can be null");
- if (from.equals(to))
- throw new IllegalArgumentException("Cannot create converter with two equal currencies");
- this.from = from;
- this.to = to;
- this.rate = rate;
- }
-
- @Override
- public double convert(double value, String from, String to)
- throws CurrencyConversionException, NullPointerException {
- return convert(value, Currency.getInstance(from), Currency.getInstance(to));
- }
-
- @Override
- public double convert(double value, Currency from, Currency to)
- throws NullPointerException, CurrencyConversionException {
-
- if (this.from.equals(from)) {
- if (!this.to.equals(to))
- throw new CurrencyConversionException(from, to, "Unsupported currency");
- return value * rate;
- }
- if (this.from.equals(to)) {
- if (!this.to.equals(from))
- throw new CurrencyConversionException(from, to, "Unsupported currency");
- return value / rate;
- }
- throw new CurrencyConversionException(from, to, "Unsupported currency");
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConversionException.java
--- a/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConversionException.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.*;
-
-/**
- * Exception thrown in cases that a CurrencyConverter is unable ensure requested accuracy of conversion.
- * Such situation may occur in cases that the client is not on-line, or the exchange rates are older than
- * requested etc. This exception is defined as RuntimeException to enable simple usage in simple applications,
- * but enable other applications to be informed about possible problems and prevent them from using
- * inaccurate data.
- */
-public final class CurrencyConversionException extends RuntimeException {
-
- private final Currency from;
- private final Currency to;
-
- CurrencyConversionException(Currency from, Currency to) {
- this(from, to, (Throwable) null);
- }
-
- CurrencyConversionException(Currency from, Currency to, Throwable throwable) {
- this(from, to, String.format("Failed to convert curency from %1$s to %2$s", from, to), throwable);
- }
-
- CurrencyConversionException(Currency from, Currency to, String message) {
- this(from, to, message, null);
- }
-
- CurrencyConversionException(Currency from, Currency to, String message, Throwable throwable) {
- super(message, throwable);
- this.from = from;
- this.to = to;
- }
-
- public Currency getFromCurrency() {
- return from;
- }
-
- public Currency getToCurrency() {
- return to;
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverter.java
--- a/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverter.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.*;
-
-/** This is the skeleton class for your API. You need to make it public, so
- * it is accessible to your client code (currently in Task1Test.java) file.
- *
- * Feel free to create additional classes or rename this one, just keep all
- * the API and its implementation in this package. Do not spread it outside
- * to other packages.
- *
- * The converter will usually work internally with Currency class, to be more type-safe as String can be used
- * for almost anything. But methods taking strings as parameters are provided for convenience.
- */
-public interface CurrencyConverter {
-
- /**
- * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
- *
- * @param value that should be converted form one currency to the other
- * @param from ISO-4217 code of the currency of the value provided
- * @param to ISO-4212 code of the currency to which the value should be converted
- * @return value expressed in the target value
- * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
- * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
- * for example the exchange rates are not current, connection to exchange rates provider is not available
- * @throws NullPointerException if any of the specified currency ISO codes is null
- */
- // this method is provided to ensure future compatibility for converters supporting more than 2 currencies
- // - simpler methods with fewer arguments would make using such converters less intuitive
- double convert(double value, /*@NotNull*/ String from, /*@NotNull*/ String to)
- throws CurrencyConversionException, NullPointerException, IllegalArgumentException;
-
- /**
- * Converts the specified value from one currency (from) to target currency (to).
- *
- * @param value that should be converted form one currency to the other
- * @param from ISO-4217 code of the currency of the value provided
- * @param to ISO-4212 code of the currency to which the value should be converted
- * @return value expressed in the target value
- * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
- * @throws CurrencyConversionException if the conversion cannot be performed with desired parameters,
- * for example the exchange rates are not current, connection to exchange rates provider is not available
- * @throws NullPointerException if any of the specified currency ISO codes is null
- */
- double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
- throws CurrencyConversionException, NullPointerException;
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.java
--- a/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyConverterProvider.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.*;
-
-/**
- * CurrencyConversionService provides methods necessary for construction all necessary currency
- * conversion-related classes.
- */
-public interface CurrencyConverterProvider {
-
- /**
- * Convenience method for getConverter(amount1, Currency.getInstance(currency1));
- *
- * @param amount1 amount of the money in the currency1
- * @param currency1 one of the supported currencies
- * @param amount2 amount of the money in the currency2
- * @param currency2 one of the supported currencies
- * @return converter able to convert between the two specified currencies
- * @throws IllegalArgumentException if any of the amount values is not positive
- * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
- */
- CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
- double amount2, /*@NotNull*/ String currency2)
- throws IllegalArgumentException, CurrencyNotAvailableException;
-
- /**
- * Retrieves converter that is capable of converting values between currency1 and currency2.
- * The exchange is specified in easy to understand way. By specifying values in two currencies that
- * are equal. For example CurrencyConverter.getConverter(25, "CZK", 1, "EUR"); means 25CKZ is equal to 1EUR.
- * This enables user to use this method without having to calculate anything. In general this can be
- * expressed by formula amount1[currency1] = amount2[currency2].
- *
- * @param amount1 amount of the money in the currency1
- * @param currency1 one of the supported currencies
- * @param amount2 amount of the money in the currency2
- * @param currency2 one of the supported currencies
- * @return converter able to convert between the two specified currencies
- * @throws IllegalArgumentException if any of the amount values is not positive
- * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
- */
- CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
- double amount2, /*@NotNull*/ Currency currency2)
- throws IllegalArgumentException, CurrencyNotAvailableException;
-
- /**
- * Creates a new converter that is able to convert between all specified currencies. The converter
- * may optionally support additional currencies that were not specified.
- *
- * @param currencies that the converter should be created for
- * @return converter able to convert between all specified currencies
- * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
- * @throws NullPointerException if any of the specified currencies is null of the array is null
- */
- CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies)
- throws CurrencyNotAvailableException, NullPointerException;
-
- /**
- * Convenient method for getConverter(Currency...)
- *
- * @param currencies that the converter should be created for
- * @return converter able to convert between all specified currencies
- * @throws CurrencyNotAvailableException thrown when one of the currencies is not available
- * @throws NullPointerException if any of the specified currencies is null, or the array is null
- * @throws IllegalArgumentException if any of the specified currencies is not a valid ISO code
- */
- CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
- throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException;
-}
\ No newline at end of file
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/src/org/apidesign/apifest08/currency/CurrencyNotAvailableException.java
--- a/task2/solution10/src/org/apidesign/apifest08/currency/CurrencyNotAvailableException.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.*;
-
-public final class CurrencyNotAvailableException extends RuntimeException {
-
- private final Currency currency;
-
- CurrencyNotAvailableException(Currency currency) {
- this(currency, String.format("Currency %1$s not available", currency));
- }
-
- CurrencyNotAvailableException(Currency currency, String message) {
- super(message);
- this.currency = currency;
- }
-
- public Currency getCurrency() {
- return currency;
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/src/org/apidesign/apifest08/currency/MultiCurrencyConstantRateConverter.java
--- a/task2/solution10/src/org/apidesign/apifest08/currency/MultiCurrencyConstantRateConverter.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.*;
-
-final class MultiCurrencyConstantRateConverter implements CurrencyConverter {
-
- private final Map rates;
-
- public MultiCurrencyConstantRateConverter(Map rates) {
- this.rates = rates;
- }
-
- /**
- * This is convenience method for convert(Currency.getInstance(from), Currency.getInstance(to)).
- *
- * @param value that should be converted form one currency to the other
- * @param from ISO-4217 code of the currency of the value provided
- * @param to ISO-4212 code of the currency to which the value should be converted
- *
- * @return value expressed in the target value
- *
- * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
- * @throws CurrencyConversionException
- * if the conversion cannot be performed with desired parameters, for
- * example the exchange rates are not current, connection to exchange rates
- * provider is not available
- * @throws NullPointerException if any of the specified currency ISO codes is null
- */
- // this method is provided to ensure future compatibility for converters supporting more than 2 currencies
- // - simpler methods with fewer arguments would make using such converters less intuitive
- @Override
- public double convert(double value, /*@NotNull*/ String from, /*@NotNull*/ String to)
- throws CurrencyConversionException, NullPointerException, IllegalArgumentException {
- return convert(value, Currency.getInstance(from), Currency.getInstance(to));
- }
-
- /**
- * Converts the specified value from one currency (from) to target currency (to).
- *
- * @param value that should be converted form one currency to the other
- * @param from ISO-4217 code of the currency of the value provided
- * @param to ISO-4212 code of the currency to which the value should be converted
- *
- * @return value expressed in the target value
- *
- * @throws IllegalArgumentException if any of the arguments is not a valid ISO code
- * @throws CurrencyConversionException
- * if the conversion cannot be performed with desired parameters, for
- * example the exchange rates are not current, connection to exchange rates
- * provider is not available
- * @throws NullPointerException if any of the specified currency ISO codes is null
- */
- @Override
- public double convert(double value, /*@NotNull*/ Currency from, /*@NotNull*/ Currency to)
- throws CurrencyConversionException, NullPointerException {
-
- // this is not necessary, but we let users know that nulls are not allowed here - should be handled by annotations
- if (from == null || to == null)
- throw new NullPointerException("One of the specified currencies in null");
-
- Double fromRate = rates.get(from);
- Double toRate = rates.get(to);
-
- if (fromRate == null)
- throw new CurrencyConversionException(from, to, String.format("Currency %1$s not supported", from));
- if (toRate == null)
- throw new CurrencyConversionException(from, to, String.format("Currency %1$s not supported", to));
-
- return (value / fromRate) * toRate;
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/src/org/apidesign/apifest08/currency/OfflineConverterProvider.java
--- a/task2/solution10/src/org/apidesign/apifest08/currency/OfflineConverterProvider.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-package org.apidesign.apifest08.currency;
-
-import java.util.*;
-
-/**
- * ConvertorProvider class is introduced to handle
- */
-public final class OfflineConverterProvider implements CurrencyConverterProvider {
-
-
- // we can't synchronize on DEFAULT as it's not final and can even be null in synchronized section
- private static final Object LOCK = new Object();
- private static CurrencyConverterProvider DEFAULT;
-
- // this is not nice and could be static, but future usage is uncertain and it's pretty easy to create
- private final Map rates;
-
- private OfflineConverterProvider() {
- rates = new HashMap();
- // simple initialization just for Task1Test
- rates.put(Currency.getInstance("USD"), 100.0);
- rates.put(Currency.getInstance("CZK"), 1700.0);
- rates.put(Currency.getInstance("SKK"), 2125.0);
- }
-
- /**
- * Provides default implementation of ConvertorProvider. This Converter does nos not ensure accuracy
- * of exchange rates, but should be functional at any circumstances including being offline.
- *
- * @return
- */
- public static CurrencyConverterProvider getInstance() {
- // should be necessary in current implementation as creating CurrencyConverterProvider is cheap, but for future
- if (DEFAULT == null)
- synchronized (LOCK) {
- if (DEFAULT == null)
- DEFAULT = new OfflineConverterProvider();
- }
- return DEFAULT;
- }
-
- @Override
- public CurrencyConverter getConverter(double amount1, /*@NotNull*/ String currency1,
- double amount2, /*@NotNull*/ String currency2)
- throws IllegalArgumentException {
-
- return getConverter(amount1, Currency.getInstance(currency2), amount2, Currency.getInstance(currency1));
- }
-
- /**
- * Retrieves converter that is capable of converting values between currency1 and currency2. The exchange is
- * specified in easy to understand way. By specifying values in two currencies that are equal. For example
- * CurrencyConverter.getConverter(25, "CZK", 1, "EUR"); means 25CKZ is equal to 1EUR. This enables user to
- * use this method without having to calculate anything. In general this can be expressed by formula
- * amount1[currency1] = amount2[currency2].
- *
- * @param amount1
- * @param currency1
- * @param amount2
- * @param currency2
- *
- * @return
- *
- * @throws IllegalArgumentException
- * @throws CurrencyNotAvailableException
- *
- */
- @Override
- public CurrencyConverter getConverter(double amount1, /*@NotNull*/ Currency currency1,
- double amount2, /*@NotNull*/ Currency currency2)
- throws IllegalArgumentException, CurrencyNotAvailableException {
- if (amount1 <= 0.0 || amount2 <= 0.0)
- throw new IllegalArgumentException(
- String.format("The specified currency values (%1$s, %2$s)", amount1, amount2));
- return new ConstantRateConverter(currency2, currency1, amount2 / amount1);
- }
-
- /**
- * Creates a new converter that is able to convert between all specified currencies.
- *
- * @param currencies that the converter should be created for
- *
- * @return converter able to convert between all specified currencies
- *
- * @throws CurrencyNotAvailableException
- * thrown when one of the currencies is not available
- */
- @Override
- public CurrencyConverter getConverter(/*@NotNull*/ Currency... currencies) throws CurrencyNotAvailableException {
- for (Currency c : currencies) {
- if (c == null)
- throw new NullPointerException("One of the specified currencies is null");
- if (!rates.containsKey(c))
- throw new CurrencyNotAvailableException(c);
- }
- return new MultiCurrencyConstantRateConverter(rates);
- }
-
- /**
- * Creates a new converter that is able to convert between all specified currencies.
- *
- * @param currencies that the converter should be created for
- *
- * @return converter able to convert between all specified currencies
- *
- * @throws CurrencyNotAvailableException
- * thrown when one of the currencies is not available
- * @throws NullPointerException if any of the specified currencies is null
- * @throws IllegalArgumentException if any of the specified currencies is not a valid ISO code
- */
- @Override
- public CurrencyConverter getConverter(/*@NotNull*/ String... currencies)
- throws CurrencyNotAvailableException, IllegalArgumentException, NullPointerException {
-
- Currency[] c2 = new Currency[currencies.length];
- for (int i = 0; i < c2.length; i++)
- c2[i] = Currency.getInstance(currencies[i]);
- return getConverter(c2);
- }
-}
diff -r a7e6f84fb078 -r 2c8c32ad44f7 task2/solution10/test/org/apidesign/apifest08/test/Task1Test.java
--- a/task2/solution10/test/org/apidesign/apifest08/test/Task1Test.java Tue Oct 07 01:18:23 2008 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-package org.apidesign.apifest08.test;
-
-import junit.framework.*;
-import org.apidesign.apifest08.currency.*;
-
-import java.util.*;
-
-/** Finish the Convertor API, and then write bodies of methods inside
- * of this class to match the given tasks. To fullfil your task, use the
- * API define in the org.apidesign.apifest08.currency
package.
- * Do not you reflection, or other hacks as your code
- * shall run without any runtime permissions.
- */
-public class Task1Test extends TestCase {
-
- private static final String
- USD = "USD",
- CZK = "CZK",
- SKK = "SKK";
-
- private static final Currency
- USD2 = Currency.getInstance(USD),
- CZK2 = Currency.getInstance(CZK),
- SKK2 = Currency.getInstance(SKK);
-
- public Task1Test(String testName) {
- super(testName);
- }
-
- @Override
- protected void setUp() throws Exception {
- }
-
- @Override
- protected void tearDown() throws Exception {
- }
-
- /** Create convertor that understands two currencies, CZK and
- * USD. Make 1 USD == 17 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting USD to CZK and CZK to USD
- */
- public static CurrencyConverter createCZKtoUSD() {
- return OfflineConverterProvider.getInstance().getConverter(17, CZK, 1, USD);
- }
-
- public static CurrencyConverter createCZKtoUSD2() {
- return OfflineConverterProvider.getInstance().getConverter(CZK, USD);
- }
-
- /** Create convertor that understands two currencies, CZK and
- * SKK. Make 100 SKK == 80 CZK.
- *
- * Creation of the convertor shall not require subclassing of any class
- * or interface on the client side.
- *
- * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
- */
- public static CurrencyConverter createSKKtoCZK() {
- return OfflineConverterProvider.getInstance().getConverter(100, SKK, 80, CZK);
- }
-
- public static CurrencyConverter createSKKtoCZK2() {
- return OfflineConverterProvider.getInstance().getConverter(SKK, CZK);
- }
-
- /** Use the convertor from createCZKtoUSD
method and do few conversions
- * with it.
- */
- public void testCurrencyCZKUSD() throws Exception {
- CurrencyConverter c = createCZKtoUSD();
- testCZKUSD(c);
-
- // test without specifying rates
- c = createCZKtoUSD2();
- testCZKUSD(c);
- }
-
- private void testCZKUSD(CurrencyConverter c) {
- double czk, usd;
- // convert $5 to CZK using c:
- // assertEquals("Result is 85 CZK");
- czk = c.convert(5, USD, CZK);
- assertEquals(85.0, czk, 0.0);
- czk = c.convert(5, USD2, CZK2);
- assertEquals(85.0, czk, 0.0);
-
- // convert $8 to CZK
- // assertEquals("Result is 136 CZK");
- czk = c.convert(8, USD, CZK);
- assertEquals(136.0, czk, 0.0);
- czk = c.convert(8, USD2, CZK2);
- assertEquals(136.0, czk, 0.0);
-
- // convert 1003CZK to USD
- // assertEquals("Result is 59 USD");
- usd = c.convert(1003, CZK, USD);
- assertEquals(59.0, usd, 0.0);
- usd = c.convert(1003, CZK2, USD2);
- assertEquals(59.0, usd, 0.0);
- }
-
- /** Use the convertor from createSKKtoCZK
method and do few conversions
- * with it.
- */
- public void testCurrencySKKCZK() throws Exception {
- CurrencyConverter c = createSKKtoCZK();
- testCZKSKK(c);
-
- // test without specifying rates
- c = createSKKtoCZK2();
- testCZKSKK(c);
- }
-
- private void testCZKSKK(CurrencyConverter c) {
- double czk, skk;
- // convert 16CZK using c:
- // assertEquals("Result is 20 SKK");
- skk = c.convert(16, CZK, SKK);
- assertEquals(20.0, skk, 0.0);
- skk = c.convert(16, CZK2, SKK2);
- assertEquals(20.0, skk, 0.0);
-
- // convert 500SKK to CZK
- // assertEquals("Result is 400 CZK");
- czk = c.convert(500, SKK, CZK);
- assertEquals(400.0, czk, 0.0);
- czk = c.convert(500, SKK2, CZK2);
- assertEquals(400.0, czk, 0.0);
- }
-}
\ No newline at end of file