This kata comes from Saleem Siddiqui 's book
We have to build a spreadsheet to manage money in more than one currency : perhaps to manage a stock portfolio ?
Stock | Stock exchange | Shares | Share Price | Total |
---|---|---|---|---|
IBM | NASDAQ | 100 | 124 USD | 12400 USD |
BMW | DAX | 400 | 75 EUR | 30000 EUR |
Samsung | KSE | 300 | 68000 KRW | 20400000 KRW |
To build it, we'd need to do simple arithmetic operations on numbers :
5 USD x 2 = 10 USD
4002 KRW / 4 = 1000.5 KRW
// convert
5 USD + 10 EUR = 17 USD
1 USD + 1100 KRW = 2200 KRW
- We can use this table to determine exchange rates :
From | To | Rate |
---|---|---|
EUR | USD | 1.2 |
USD | EUR | 0.82 |
USD | KRW | 1100 |
KRW | EUR | 0.0009 |
EUR | KRW | 1344 |
KRW | EUR | 0.00073 |
We have already started the implementation by using TDD. We have discovered examples that helped us drive our implementation.
Money Calculator :
✅ 10 EUR x 2 = 20 EUR
✅ 4002 KRW / 4 = 1000.5 KRW
✅ 5 USD + 10 USD = 15 USD
Bank implementation :
✅ Determine exchange rate based on the currencies involved (from -> to)
✅ Improve the implementation of exchange rates
✅ Allow exchange rates to be modified