1.1 --- a/.hgignore Sun Sep 28 18:44:34 2008 +0200
1.2 +++ b/.hgignore Sun Sep 28 20:07:04 2008 +0200
1.3 @@ -1,4 +1,5 @@
1.4 .*/private/.*
1.5 .*/dist/.*
1.6 .*/build/.*
1.7 +.*orig
1.8
2.1 --- a/currency/test/org/apidesign/apifest08/test/Task1Test.java Sun Sep 28 18:44:34 2008 +0200
2.2 +++ b/currency/test/org/apidesign/apifest08/test/Task1Test.java Sun Sep 28 20:07:04 2008 +0200
2.3 @@ -22,8 +22,19 @@
2.4 protected void tearDown() throws Exception {
2.5 }
2.6
2.7 + //
2.8 + // Imagine that there are three parts of the whole system:
2.9 + // 1. there is someone who knows the current exchange rate
2.10 + // 2. there is someone who wants to do the conversion
2.11 + // 3. there is the API between 1. and 2. which allows them to communicate
2.12 + // Please design such API
2.13 + //
2.14 +
2.15 /** Create convertor that understands two currencies, CZK and
2.16 - * USD. Make 1 USD == 17 CZK.
2.17 + * USD. Make 1 USD == 17 CZK. This is a method provided for #1 group -
2.18 + * e.g. those that know the exchange rate. They somehow need to create
2.19 + * the objects from the API and tell them the exchange rate. The API itself
2.20 + * knows nothing about any rates, before the createCZKtoUSD method is called.
2.21 *
2.22 * Creation of the convertor shall not require subclassing of any class
2.23 * or interface on the client side.
2.24 @@ -35,7 +46,11 @@
2.25 }
2.26
2.27 /** Create convertor that understands two currencies, CZK and
2.28 - * SKK. Make 100 SKK == 80 CZK.
2.29 + * SKK. Make 100 SKK == 80 CZK. Again this is method for the #1 group -
2.30 + * it knows the exchange rate, and needs to use the API to create objects
2.31 + * with the exchange rate. Anyone shall be ready to call this method without
2.32 + * any other method being called previously. The API itself shall know
2.33 + * nothing about any rates, before this method is called.
2.34 *
2.35 * Creation of the convertor shall not require subclassing of any class
2.36 * or interface on the client side.
2.37 @@ -45,6 +60,13 @@
2.38 public static Convertor createSKKtoCZK() {
2.39 return null;
2.40 }
2.41 +
2.42 + //
2.43 + // now the methods for group #2 follow:
2.44 + // this group knows nothing about exchange rates, but knows how to use
2.45 + // the API to do conversions. It somehow (by calling one of the factory
2.46 + // methods) gets objects from the API and uses them to do the conversions.
2.47 + //
2.48
2.49 /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
2.50 * with it.
2.51 @@ -72,5 +94,20 @@
2.52 // convert 500SKK to CZK
2.53 // assertEquals("Result is 400 CZK");
2.54 }
2.55 +
2.56 + /** Verify that the CZK to USD convertor knows nothing about SKK.
2.57 + */
2.58 + public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
2.59 + Convertor c = createCZKtoUSD();
2.60 + // convert $5 to SKK, the API shall say this is not possible
2.61 + // convert 500 SKK to CZK, the API shall say this is not possible
2.62 + }
2.63 +
2.64 + /** Verify that the CZK to SKK convertor knows nothing about USD.
2.65 + */
2.66 + public void testCannotConvertToSKKwithCZKUSDConvertor() throws Exception {
2.67 + Convertor c = createSKKtoCZK();
2.68 + // convert $5 to SKK, the API shall say this is not possible
2.69 + // convert 500 CZK to USD, the API shall say this is not possible
2.70 + }
2.71 }
2.72 -