Explaining that the API and its impl shall be kept in one package.
Also stressing that the Convertor shall be "pre-made" in the API, no subclassing needed to create its implementation.
1 package org.apidesign.apifest08.test;
3 import junit.framework.TestCase;
4 import org.apidesign.apifest08.currency.Convertor;
6 /** Finish the Convertor API, and then write bodies of methods inside
7 * of this class to match the given tasks. To fullfil your task, use the
8 * API define in the <code>org.apidesign.apifest08.currency</code> package.
9 * Do not you reflection, or other hacks as your code
10 * shall run without any runtime permissions.
12 public class Task1Test extends TestCase {
13 public Task1Test(String testName) {
18 protected void setUp() throws Exception {
22 protected void tearDown() throws Exception {
25 /** Create convertor that understands two currencies, CZK and
26 * USD. Make 1 USD == 17 CZK.
28 * Creation of the convertor shall not require subclassing of any class
29 * or interface on the client side.
31 * @return prepared convertor ready for converting USD to CZK and CZK to USD
33 public static Convertor createCZKtoUSD() {
37 /** Create convertor that understands two currencies, CZK and
38 * SKK. Make 100 SKK == 80 CZK.
40 * Creation of the convertor shall not require subclassing of any class
41 * or interface on the client side.
43 * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
45 public static Convertor createSKKtoCZK() {
49 /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
52 public void testCurrencyCZKUSD() throws Exception {
53 Convertor c = createCZKtoUSD();
54 // convert $5 to CZK using c:
55 // assertEquals("Result is 85 CZK");
58 // assertEquals("Result is 136 CZK");
60 // convert 1003CZK to USD
61 // assertEquals("Result is 59 USD");
64 /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
67 public void testCurrencySKKCZK() throws Exception {
68 Convertor c = createSKKtoCZK();
69 // convert 16CZK using c:
70 // assertEquals("Result is 20 SKK");
72 // convert 500SKK to CZK
73 // assertEquals("Result is 400 CZK");